天天看點

Mybatis 屬性 無法 指派

問題描述 :

public class AbstractPersistentInfo implements IAbstractPersistentInfo {
    private static final long serialVersionUID = L;

    public static String ID = "id"; //問題在這裡

    private Long id;

    ...set/get  
}
           
public class look extends AbstractPersistentInfo {
    private static final long serialVersionUID =L;
}
           
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="xxx.look">
    <select id="getById" parameterType="long" resultType="xxx.look">
        select id from T_look where id=#{id}
    </select>
</mapper>
           

出現使用resultType無法指派到id.

問題

Mybatis 在 getProperty 的時候 ,忽略大小寫. 會預設取到第一個 ID

解決

ID 重命名 成 CL_ID

總結

Mybatis 出現問題,使用Debug可以跟蹤并解決. 建議采用IDEA的Debug功能,可以追述上下文.

    • 問題描述
    • 問題
    • 解決
    • 總結

繼續閱讀