目录Mysql mybatis 默认插入当前时间MyBatis 插入时间类型的数据mysql MyBatis 默认插入当前时间 <!--单表动态更新语句 -->
<!--单表动态更新语句 -->
<update id="update" parameterType="com.zzg.entity.ColumnValidate">
update ucas_bus_column_validate
<set>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="state != null and state != ''">
`state` = #{state,jdbcType=VARCHAR},
</if>
<if test="deleteFlag != null and deleteFlag != ''">
delete_flag = #{deleteFlag,jdbcType=VARCHAR},
</if>
<if test="validateName != null and validateName != ''">
validate_name = #{validateName,jdbcType=VARCHAR},
</if>
<if test="validateContent != null and validateContent != ''">
validate_content = #{validateContent,jdbcType=VARCHAR},
</if>
version = version + 1,
update_dt = now()
</set>
where sid = #{sid,jdbcType=VARCHAR} and version = #{version, jdbcType=INTEGER}
</update>
重点代码:update_dt = now()
数据库indbTime字段类型:date
实体中类型是:Date
mybatis的插入类型应该设置成:#{indbTime,jdbcType=TIMESTAMP}
mybatis的插入类型应该设置成: #{indbTime,jdbcType=DATE}
insert into CDS_DATA_PLAT_TRANS_INFO
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="indbTime != null">
INDB_TIME,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="indbTime != null">
#{indbTime,jdbcType=TIMESTAMP},
</if>
</trim>
</insert>
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。
--结束END--
本文标题: MySQL MyBatis 默认插入当前时间方式
本文链接: https://www.lsjlt.com/news/169246.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
2024-05-03
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0