求助myBatis sqlMap foreach 对象中的list传入,报错

xingbaozhushu 2014-12-01 05:49:05

myBatis sqlMap foreach 对象中的list传入,报错,再此向各位大神求助
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_item_0' in 'class com.asiacloud.core.model.PageModel'
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:75)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:368)
at $Proxy6.selectList(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:198)
at com.asiacloud.core.base.dao.impl.BaseDaoImpl.select(BaseDaoImpl.java:74)
at com.asiacloud.syse.unitaccount.dao.impl.TSyseMaintainAccountDaoImpl.queryListByUnitIdPage(TSyseMaintainAccountDaoImpl.java:107)

action中的代码

...
private PageModel page = new PageModel();
...
tSyseMaintainAccount.setIdList(idList);
tSyseMaintainAccount.setId(loginId);
page.setParams(tSyseMaintainAccount);
page = iTSyseMaintainAccountService.queryListByUnitIdPage(page);

sqlMap文件:
<select id="queryListByUnitIdPage" parameterType="TSyseMaintainAccount" resultMap="TSyseMaintainAccountResultMap">
select a.*,b.UNIT_NAME linkUnitName from T_SYSE_MAINTAIN_ACCOUNT a
left JOIN T_SYSE_OPER_UNIT b
on a.UNIT_ID=b.ID
where a.STATUS_FLAG in ('1','2')
AND a.UNIT_ID in
<foreach item="item" index="index" collection="params.idList" open="(" separator="," close=")">
#{item}
</foreach>
AND a.ID != #{params.id}
</select>


TSyseMaintainAccount类:
public class TSyseMaintainAccount implements java.io.Serializable {

// Fields
private Long id;
private String name;
...
private List idList;
public List getIdList() {
return idList;
}

public void setIdList(List idList) {
this.idList = idList;
}


}

PageModel类

public class PageModel {
...
private Object params;
public Object getParams() {
return params;
}

public void setParams(Object params) {
this.params = params;
}
...
}
...全文
6152 13 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
浅笑- 2016-09-10
  • 打赏
  • 举报
回复
问题自己一解决 Map<String,Object> params = new HashMap<String,Object>(); params.put("123","123"); params.put("456","456"); List<Object> list = new ArrayList<Object>(); Map<String,Object> map = new HashMap<String,Object>(); map.put("startTime","2016"); map.put("endTime","2017"); list.add(map); map.put("startTime","2018"); map.put("endTime","2019"); list.add(map); params.put("yearList",list); 这样我出入的是map,而map里我要用到的yearList里面的startTime和endTime,而最终是要 <foreach collection="yearList" item="item" open="AND (" close=")" index="index"> <if test="${index}!=0">OR</if> ( T.START_TIME >= [这里怎么取到startTime] AND T.START_TIME <= [这里怎么取到endTime] ) </foreach>
浅笑- 2016-09-10
  • 打赏
  • 举报
回复
Map<String,Object> params = new HashMap<String,Object>(); params.put("123","123"); params.put("456","456"); List<Object> list = new ArrayList<Object>(); Map<String,Object> map = new HashMap<String,Object>(); map.put("startTime","2016"); map.put("endTime","2017"); list.add(map); map.put("startTime","2018"); map.put("endTime","2019"); list.add(map); params.put("yearList",list); 这样我出入的是map,而map里我要用到的yearList里面的startTime和endTime,而最终是要 <foreach collection="yearList" item="item" open="AND (" close=")" index="index"> <if test="${index}!=0">OR</if> ( T.START_TIME >= [这里怎么取到startTime] AND T.START_TIME <= [这里怎么取到endTime] ) </foreach>
javatrsghr 2015-10-14
  • 打赏
  • 举报
回复
感谢楼主,用楼主的方法解决了我的问题
zxc8023tt 2015-06-30
  • 打赏
  • 举报
回复
太感谢了!!
xingbaozhushu 2014-12-03
  • 打赏
  • 举报
回复
插入代码变不了颜色啊。 <foreach item="item" index="index" collection="params.idList" open="(" separator="," close=")"> #{params.idList[${index}]} </foreach>
xingbaozhushu 2014-12-03
  • 打赏
  • 举报
回复
参照http://blog.sina.com.cn/s/blog_6daf49ad0101fits.html已经解决了问题。 foreach处的sql语句的写法错了。 应该是为:
<foreach item="item" index="index" collection="params.idList" open="(" separator="," close=")">  
                      #{params.idList[${index}]}
            </foreach> 
xingbaozhushu 2014-12-03
  • 打赏
  • 举报
回复
改成了parameterType="com.asiacloud.syse.unitaccount.model.TSyseMaintainAccount" 还是报错 There is no getter for property named '__frch_item_0' in 'class com.asiacloud.core.model.PageModel' 我不理解这句异常到底指的是什么地方的getter方法没有啊?
qin34 2014-12-02
  • 打赏
  • 举报
回复
假如你想用parameterMap,那么你在<select id="queryListByUnitIdPage" parameterType="TSyseMaintainAccount" resultMap="TSyseMaintainAccountResultMap">中的parameterType应该写成parameterMap 或者 parameterType="包名.TSyseMaintainAccount"
xingbaozhushu 2014-12-01
  • 打赏
  • 举报
回复
各位大神,还请指点迷津。
xingbaozhushu 2014-12-01
  • 打赏
  • 举报
回复
<parameterMap type="TSyseMaintainAccount" id="TSyseMaintainAccount">
		<parameter property="id" />
		<parameter property="name" />
		<parameter property="male" />
		<parameter property="logAcc" />
		<parameter property="passwd" />
		<parameter property="birthDate" />
		<parameter property="unitId" />
		<parameter property="begDate" />
		<parameter property="endDate" />
		<parameter property="curTime" />
		<parameter property="cOptId" />
		<parameter property="optDeviceCode" />
		<parameter property="statusFlag" />
???
	</parameterMap>
???处是否要加上<parameter property="idList" />呢?但是这么加上肯定不对啊。
xingbaozhushu 2014-12-01
  • 打赏
  • 举报
回复
get和set方法应该没问题,sql语句也找不到问题,感觉应该是parameterType配错了,少了IDList一项,但是不知道如何去写。 稍后附上代码
qin34 2014-12-01
  • 打赏
  • 举报
回复
找到哪里出错了吗?
qzw1210 2014-12-01
  • 打赏
  • 举报
回复
重点检查sql语句和参数匹配,报的是无getter和setter。

67,549

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧