使用mybatis
遇到一个非常奇葩的问题,错误如下:
Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column 'name' from result set. Cause: java.sql.SQLException: Invalid value for getInt() - 'wo'
场景
还原一下当时的情况:
public interface UserMapper {
@Results(value = {
@Result(property = "id", column = "id", javaType = Long.class, jdbcType = JdbcType.BIGINT),
@Result(property = "age", column = "age", javaType = Integer.class, jdbcType = JdbcType.INTEGER),
@Result(property = "name", column = "name", javaType = String.class, jdbcType = JdbcType.VARCHAR)
})
@Select("SELECT id, name, age FROM user WHERE id = #{id}")
User selectUser(Long id);
}
@Data
@Builder
public class User {
private Long id;
private Integer age;
private String name;
}
public class MapperMain {
public static void main(String[] args) throws Exception {
MysqlConn