Error attempting to get column 'xxx' from result set

报错如下:

{
  "timestamp": "2020-04-08T14:55:17.014+0000",
  "status": 500,
  "error": "Internal Server Error",
  "message": "nested exception is org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'relation' from result set.  Cause: java.lang.IllegalArgumentException: No enum constant edu.lhy.poe.model.enums.LikeRelationType.0",
  "trace": "org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'relation' from result set.  Cause: java.lang.IllegalArgumentException: No enum constant edu.lhy.poe.model.enums.LikeRelationType.0\r\n\tat org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)\r\n\tat org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)\r\n\tat com.sun.proxy.$Proxy89.selectList(Unknown Source)\r\n\tat org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223)\r\n\tat org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147)\r\n\tat org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80)\r\n\tat org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:144)\r\n\tat org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:85)\r\n\tat com.sun.proxy.$Proxy99.selectByRelationTypeAndStuffType(Unknown Source)\r\n\tat edu.lhy.poe.controller.UserController.searchLike(UserController.java:82)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\r\n\tat sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)\r\n\tat 

我最开始以为是字段映射问题(通常情况下都是如此)。在MySQL的字段是tinyint,java中的byte,jdbcType是TINYINT。后来发现这是正确的,

错误的原因是,实体类的重载——为了方便写了一个set方法将enum类型转化为byte,最后导致报错了。删除参数类型为enum的方法即可

Error attempting to get column 'xxx' from result set_第1张图片

另:@Setter只会在没有setXxx()方法时自动生成setXxx()

 

你可能感兴趣的:(mybatis,java,mysql)