Mybatis resultmap无法映射字符串类型

时间:2017-06-26 16:40:22

标签: mybatis resultset

<mapper namespace="EmployeeMapper">
<resultMap id="employeeResultMap"
           type="EmployeeInfo">
    <result property="employeeId" column="current.employee_id"/>
    <result property="employeeName" column="current.employee_name"/>
    <result property="job" column="current.job"/>
</resultMap>

<select id="getEmployeeData" parameterType="list" resultMap="employeeResultMap">
    SELECT current.employee_id, emp.employee_name , current.job
    FROM Employees emp join Jobs current on emp.employee_id = 
     current.employee_id 
</select>

EmployeeId是整数,员工姓名是字符串。 但EmployeeId正确映射,而员工名称映射为null。如果我将查询更改为

SELECT current.employee_id as employeeId, emp.employee_name as employeeName, 
current.job as job
FROM Employees emp join Jobs current on emp.employee_id = 
 current.employee_id 

工作正常。

1 个答案:

答案 0 :(得分:0)

从resultMap中删除$ cygcheck -l cygwin-debuginfo | grep -i "s$" /usr/src/debug/cygwin-2.8.1-0.1/newlib/libc/machine/x86_64/memcpy.S /usr/src/debug/cygwin-2.8.1-0.1/newlib/libc/machine/x86_64/memset.S /usr/src/debug/cygwin-2.8.1-0.1/newlib/libc/machine/x86_64/setjmp.S current.属性的值必须与SQL查询中的列名匹配(不区分大小写),默认情况下也会对camel case name mapping进行下划线。

如果同时删除column行,则可以通过自动映射确定它的工作方式相同。