MySQL中Date和DateTime字段与mybatis的对应关系

MySQL中Date和DateTime字段与mybatis的对应关系

在MySQL字段中有Date和DateTime类型,但是java中没有DateTime类型。
解决办法:
(1)在mybatis插入数据时只要将实体的属性设置成Timestamp就会对应mysql的DateTime类型,
(2)将实体的属性设置成Date会对应mysql的Date类型。
<result column="maketime" property="maketime" jdbcType="TIMESTAMP" /> <result column="activetime" property="activetime" jdbcType="DATE" />
使用过程中注意设置

<if test="maketime != null" >
        #{maketime,jdbcType=TIMESTAMP},
</if>
 <if test="activetime != null" >
        #{activetime,jdbcType=DATE},
 </if>

猜你喜欢

转载自blog.csdn.net/u010394400/article/details/84303446