zhen_away 2014-12-05 06:57 采纳率: 0%
浏览 916

mybatis高手进,SOS-mybatis执行查询时返回入参。多谢

很怪异的问题,mybatis执行查询时,返回了原本的入参。这个问题偶然在服务器上出现过几次,本地开发环境从未出现过。小弟木有金币,只能道一声感谢!多谢!
代码如下:

DAO:

try {
logger.info("---param: ID " + assReq.getId() + "--Code: " + assReq.getCode());
/**
* 怀疑是mybatis 缓存,将AssReq_findByKey 把SQL Key 值改为其他名字
* **/
Object res = this.queryForObject("AssReq_queryAssReq", assReq);
logger.info("----result: " + res);
return (AssessReq)res;
} catch (DAOException e) {
logger.error("---findAssReqByKey--DAOException ",e);
return null;
} catch (Exception e) {
logger.error("---findAssReqByKey--Exception ",e);
return null;
}

SQL:

    <select id="AssReq_queryAssReq" parameterType="com.aspire.mcts.ams.entity.ams.AssessReq" resultMap="AssReq_result" useCache="false">
    select * from ams_assess 
    <where>
        <if test="code != null and code != ''">
            AND ASSESS_CODE = #{code} 
        </if>
        <if test="id != null and id != ''">
            AND ID = #{id}
        </if>
    </where>
</select>

运行日志:

[INFO ]: 2014-11-28 13:18:56,239 :[com.aspire.mcts.ams.ass.dao.impl.AssReqDaoImpl] - ---param: ID 180--Code: null

[INFO ]: 2014-11-28 13:18:56,244 :[com.aspire.mcts.ams.ass.dao.impl.AssReqDaoImpl] - ----resutl: 180
[ERROR]: 2014-11-28 13:18:56,250 :[com.aspire.mcts.ams.ass.dao.impl.AssReqDaoImpl] - ---findAssReqByKey--Exception

java.lang.ClassCastException: java.lang.Integer cannot be cast to com.aspire.mcts.ams.entity.ams.AssessReq
at com.aspire.mcts.ams.ass.dao.impl.AssReqDaoImpl.findAssReqByKey(AssReqDaoImpl.java:86) ~[AssReqDaoImpl.class:na]
at com.aspire.mcts.ams.ass.service.impl.AssReqServiceImpl.findAssReqByKey(AssReqServiceImpl.java:55) [AssReqServiceImpl.class:na]
at com.aspire.mcts.ams.ass.service.impl.AssReqServiceImpl$$FastClassByCGLIB$$46a05f8d.invoke() [cglib-2.1.3.jar:na]
at net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:149) [cglib-2.1.3.jar:na]
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint(Cglib2AopProxy.java:689) [org.springframework.aop-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150) [org.springframework.aop-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110) [org.springframework.transaction-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [org.springframework.aop-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:90) [org.springframework.aop-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172) [org.springframework.aop-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept(Cglib2AopProxy.java:622) [org.springframework.aop-3.1.0.RELEASE.jar:3.1.0.RELEASE]
at com.aspire.mcts.ams.ass.service.impl.AssReqServiceImpl$$EnhancerByCGLIB$$efff9e81.findAssReqByKey() [cglib-2.1.3.jar:na]
at com.aspire.mcts.ams.ass.action.AssReqAction.find(AssReqAction.java:38) [AssReqAction.class:na]

  • 写回答

1条回答

  • CSDN-Ada助手 CSDN-AI 官方账号 2022-10-25 19:35
    关注
    不知道你这个问题是否已经解决, 如果还没有解决的话:

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

悬赏问题

  • ¥20 Python安装cvxpy库出问题
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥15 python天天向上类似问题,但没有清零
  • ¥30 3天&7天&&15天&销量如何统计同一行
  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题