1.实体bean:ProductType
2.字段id,name
ProductType.xml 中定义一个查询,如下:
<parameterMap type="map" id="paramMap">
<parameter property="productType" javaType="com.nd.orm.ProductType" jdbcType="OTHER" />
<parameter property="pageSize" javaType="int" jdbcType="NUMERIC"/>
</parameterMap>
<select id="getScrollPage" parameterMap="paramMap" resultType="com.nd.orm.ProductType">
select * from ProductType where 1=1
<if test="productType.name!=null and productType.name!=''">
and name like #{productType.name}
</if>
</select>
查询:
Map<String,Object> map=new HashMap<String, Object>();
ProductType a=new ProductType();
a.setName("XXXXX");//////////////////////////////注意这里
map.put("productType", a);
map.put("pageSize", 10);
List p= session.selectList("ProductType.getScrollPage", map);
问题:
如果a.setName赋值了,查询没问题
可是如果a没有setName,系统就报错:
Cause: org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for parameter productType of statement ProductType.getScrollPage
已经做判断了
and name like #{productType.name}
而且直接用 select * from ProductType 查询,冒同样的错误
这判断应该是有问题,我不知道Mybatis支不支持这么写,
我觉得你不加这个判断,
a.setName("");//////////////////////////////注意这里
给它set个空值试一下。