yaoyy09
yaoyy09
2016-01-21 03:21

Spring3整合Mybatis3+mybatis-spring1.x查询报错

  • spring
  • mybatis

我在进行Spring(V:3.2.3.RELEASE)+mybatis(V:3.2.4)+mybatis-spring(V:1.1.1)整合。有一个ClassRoom班级类:
//班级id
private int classId;
//班级编码
private String classCode;
//班级名字
private String className;
//所属学院
private College college;
//标记
private int flag;
学院类College属性是:
private int collegeId;
private String collegeCode;
private String collegeName;
private int flag;

ClassRoomMapper.xml配置如下:





<!-- -->






查询班级信息语句如下:

select t.class_id, t.class_code,t.class_name, t.flag as 'class_flag',t2.college_code, t2.college_id, t2.college_name, t2.flag as 'college_flag' from t_class t left join t_college t2 on t.college =t2.college_code where t.class_code = #{classCode}

beans.xml中配置ClassDao如下:



在进行查询(loadByCode) 的时候报错如下:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'classRoomDao'
defined in class path resource [applicationContext.xml]: Cannot resolve reference to bean 'sqlSessionFactory'
while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sqlSessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init
method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource
[mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration.
Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: java.lang.IllegalStateException:
Type handler was null on parameter mapping for property 'college'. It was either not specified and/or could not be found
for the javaType / jdbcType combination specified.

请问这是什么原因呢?还需要重新写college与数据库字段对应的关系吗?我已经在association中增加了对应字段的配置。

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

6条回答