Get Timestamp type data by truncating hours, minutes and seconds

<resultMap id="javaTypePlus2" class="java.util.HashMap">
	<result column="seirino" property="seirino" />
	<result column="time2" property="time2" jdbcType="Timestamp"
		javaType="java.util.Date" />
	<result column="time1" property="time1" jdbcType="Timestamp"
		javaType="java.sql.Timestamp" />
</resultMap>

<select id="gettime" resultMap="javaTypePlus2" parameterClass="Map">
	SELECT seirino,time1,time2 FROM TIME
</select>

If you want to truncate hours, minutes and seconds ⇒Specify java.util.Date type for javaType like time2

If you also want to get hours, minutes and seconds ⇒Specify java.sql.Timestamp type for javaType like time1

Also, as shown below, the type on the DB server side does not matter (jdbcType can be obtained regardless of Timestamp type or Date type on sqlMap)

<resultMap id="javaTypePlus2" class="java.util.HashMap">
	<result column="seirino" property="seirino" />
	<result column="time2" property="time2" jdbcType="java.util.Date"
		javaType="java.util.Date" />
	<result column="time1" property="time1" jdbcType="java.util.Date"
		javaType="java.sql.Timestamp" />
</resultMap>

Recommended Posts

Get Timestamp type data by truncating hours, minutes and seconds
Basic data type and reference type