`

org.apache.ibatis.reflection.ReflectionException: There is no getter for propert

 
阅读更多

2014-02-16 14:52:58.475:WARN:oejs.ServletHandler:/mideaAdmin/deleteUser.midea
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userIds' in 'class java.lang.String'
 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)
 at $Proxy23.update(Unknown Source)
 at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:246)
 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:62)
 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:25)
 at $Proxy30.deleteUser(Unknown Source)
 at com.hailong.midea.busi.user.manager.UserManager.deleteUser(UserManager.java:80)
 at com.hailong.midea.web.controller.user.UserController.deleteUser(UserController.java:147)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:754)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
 at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:594)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1365)
 at com.hailong.midea.web.filter.SessionFilter.doFilterInternal(SessionFilter.java:80)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1336)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:149)
 at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:111)
 at org.eclipse.jetty.server.Server.handle(Server.java:351)
 at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(AbstractHttpConnection.java:451)
 at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(AbstractHttpConnection.java:931)
 at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:857)
 at org.eclipse.jetty.http.HttpParser.parseAvailable(HttpParser.java:230)
 at org.eclipse.jetty.server.AsyncHttpConnection.handle(AsyncHttpConnection.java:76)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint.handle(SelectChannelEndPoint.java:609)
 at org.eclipse.jetty.io.nio.SelectChannelEndPoint$1.run(SelectChannelEndPoint.java:45)
 at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:599)
 at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:534)
 at java.lang.Thread.run(Thread.java:662)
Caused by:
org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userIds' in 'class java.lang.String'
 at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:308)
 at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:93)
 at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:134)
 at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:27)
 at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:103)
 at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextMap.get(DynamicContext.java:72)
 at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:90)
 at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
 at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
 at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
 at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
 at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
 at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
 at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:454)

 

 

 解决方案:
 引起问题的原因是因为在DAO方法中定义的参数 与 实体中定义的属性不一致 导致的,
 比如DAO方法定义的是:
 
 public int deleteUser(String userIds);
 
 SQL语句如下:
 <!-- 删除用户(逻辑删除) -->
 <update id="deleteUser" parameterType="String">
  UPDATE t_user t SET t.user_status = '禁用' WHERE t.user_pk_id IN(#{userIds})
 </update>
 
 UserEntity的定义:
 public class UserEntity extends AbstractEntity{
  private int userPkId;
  private String userId;
  private String userName;
  private String sex;
  private byte age;
 }
 
 这个userIds并不在UserEntity中存在,而userId是存在的,如果使用UserEntity中不存在userIds的属性 所以会报此错误。改成userId 问题即可解决。

分享到:
评论
1 楼 u012625419 2014-09-27  
   数据库映射文件数据库操作语句和 实体类中不一样

相关推荐

Global site tag (gtag.js) - Google Analytics