Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to return columns with null values in a result map in mybatis

 
Siddharth Polisity
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<select id="keyEquipmentShiftAutomatedModelData" parameterType="java.util.Map" resultType="java.util.Map">
SELECT ID, SUM(VALUE1 + VALUE2) Total
FROM tableName
GROUP BY ID
</select>

Returns below result in sql

ID, Total
1 (null)

But when returned in Map result in myBatis returns {ID=1} where as Total is missing. How to get the column with null into the result set as well something like this {ID=1,Total=null} or something like this {ID=1,Total=""}
 
Siddharth Polisity
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adding
<settings>
<setting name="callSettersOnNulls" value="true"/>
</settings>

mybatis-config.xml fixes the issue if using mybatis 3.2 + version
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!