Mybatis not setting fields if column is not specified

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Mybatis not setting fields if column is not specified

sreekanth.r.vanguru
HI,

I have the following in mapper.

<resultMap type="Interface" id="Interface">
<id column="interfaceId" property="interfaceId"/>
</resultMap>

<select id="selectInterface" parameterType="int" resultMap="Interface">
SELECT 
  interface_id as "InterfaceId",  
.db_record_status as "dbRecordStatus"
FROM interface
WHERE
  (pi.device_id = #{Id}) AND

</select>

If I don't specify 

<id column="dbRecordStatus" property="dbRecordStatus"/>

in the resultMap, then that field isn't getting set, it remains as null. But the mybatis manual says that properties should be set automatically if the column and property names match. I even tried with the following setting in mybatis.xml.

<settings> <setting name="useColumnLabel" value="true"/> </settings>

Not sure what I'm missing here, Any help would be appreciated.

sreekanth




--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Mybatis not setting fields if column is not specified

Guy Rouillier-2
Try setting automapping="true" for the resultMap.

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 6/22/2018 3:17:09 PM
Subject: Mybatis not setting fields if column is not specified

HI,

I have the following in mapper.

<resultMap type="Interface" id="Interface">
<id column="interfaceId" property="interfaceId"/>
</resultMap>

<select id="selectInterface" parameterType="int" resultMap="Interface">
SELECT 
  interface_id as "InterfaceId",  
.db_record_status as "dbRecordStatus"
FROM interface
WHERE
  (pi.device_id = #{Id}) AND

</select>

If I don't specify 

<id column="dbRecordStatus" property="dbRecordStatus"/>

in the resultMap, then that field isn't getting set, it remains as null. But the mybatis manual says that properties should be set automatically if the column and property names match. I even tried with the following setting in mybatis.xml.

<settings> <setting name="useColumnLabel" value="true"/> </settings>

Not sure what I'm missing here, Any help would be appreciated.

sreekanth




--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.