查询字段映射不上问题
现象 数据库中字段有值,但接口返回对象对应字段为 null。 SQL 单独在数据库执行是正常的。 原始SQL <select id="selectUser" resultType="com.example.User"> select user_id, user_name from user where user_id = #{id} </select> 实体类: public class User { private Long userId; private String userName; } 查询后发现 userName 为 null。 排查 数据库字段为: u u s s e e r r _ _ i n d a m e 实体类为: u u s s e e r r I N d a m e MyBatis 默认不会自动把下划线转为驼峰。 ...