开始标签:
<?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">
代码一:
<select id="selectHouse3Release" resultType="com.dhys.hourse3.dto.House3Release">
SELECT
id,
release_id
AS releaseId,
release_name AS releaseName,
project,
building,
number,
number_id AS numberId,
address,
app_id AS appId,
type_id AS typeId,
area,
orientation,
room_number AS roomNumber,
ting_number AS tingNumber,
wei_number AS weiNumber,
rent,
rental_mode AS rentalMode,
deposit,
rent_number AS rentNumber,
total_floors AS totalFloors,
floors,
fitment,
leading_person_id AS leadingPersonId,
manager_type AS managerType,
elease_status_id AS eleaseStatusId,
linkman,
linkman_phone AS
linkmanPhone,
del_flag AS delFlag,
browseNum,
huxing,
manager_cost AS
managerCost,
isTop,
creator,
create_time AS createTime,
update_time AS
updateTime,
updator
FROM
house3_release
WHERE
number_Id = #{number_Id}
AND
del_flag = "0"
</select>
代码二:
<select id="selectHouse3Release" resultType="com.dhys.hourse3.dto.House3Release">
SELECT
*
FROM
house3_release
WHERE
number_Id = #{number_Id}
AND
del_flag = "0"
</select>
这两组查询结果相同。结果如下:
{
"code": 200,
"list": {
"id": 7,
"releaseId": "222",
"releaseName": "dyy房源1",
"project": "大汉1期",
"building": "一栋",
"number": "1002号",
"numberId": "49E3A05520E7724EDE83",
"address": "大汉金桥",
"appId": null,
"typeId": "53",
"area": 30,
"orientation": "60",
"roomNumber": 3,
"tingNumber": 2,
"weiNumber": 1,
"rent": 300,
"rentalMode": "1",
"deposit": 500,
"rentNumber": "3",
"totalFloors": 15,
"floors": 4,
"fitment": "5",
"leadingPersonId": "ee0a7aeadc9e42a2bf98d7fbab705f7a",
"managerType": "1",
"eleaseStatusId": "4",
"linkman": null,
"linkmanPhone": null,
"delFlag": "0",
"browseNum": 0,
"huxing": null,
"managerCost": 0,
"isTop": null,
"creator": "",
"createTime": "2018-04-28 15:52:22",
"updateTime": "2018-05-22 08:57:56",
"updator": "admin",
"approvalOpinion": "1",
"remark": null,
"list1": null,
"list2": null,
"list3": null,
"list4": null,
"houseFile": null,
"fileId": null,
"huxingName": null
}
}
结论:当数据库的字段为下划线隔开的方式时,如果其对用的映射类成名变量是驼峰方式命名时,myBatis的映射查询结果可自动匹配。即myBatis的查询结果方式是默认自动匹配驼峰方式,不需要额外的映射配置。