解决方法三种
-
1、写SQL语句的时候 使用
as
做别名 -
2、在Mybaits的全局配置文件中开启托名命名
- 开启驼峰命名规则,可以将数据库中下划线映射为驼峰命名列如 last_name 可以映射为 lastName
<setting name="mapUnderscoreToCameLCase" value="true" />
-
3、在Mapper映射文件中使用resultMap自定义映射
<!--
自定义映射
-->
<resultMap type="com.atguigu.pojo.Employee" id="myMap">
<!-- 映射主键 -->
<id cloumn="id" property="id"/>
<!-- 映射其他列 -->
<result column="last_name" property="lastName" />
<result column="email" property="email" />
<result column="salary" property="salary" />
<result column="dept_id" property="deptId" />
</resultMap>