customerized convert from field type to DB field's type
@LastModifiedDate
@Convert(converter = LocalDateTime2TimestampConverter.class)
@Slf4j
public class LocalDateTime2TimestampConverter implements
AttributeConverter<LocalDateTime, Timestamp> {
@Override
public Timestamp convertToDatabaseColumn(LocalDateTime ld) {
return ld == null ? null : new Timestamp(ld.toDateTime().getMillis());
}
@Override
public LocalDateTime convertToEntityAttribute(Timestamp ts) {
if (ts != null) {
try {
return LocalDateTime.fromDateFields(ts);
} catch (IllegalArgumentException ex) {
log.warn("Can't convert {} to LocalDate", ts, ex);
}
}
return null;
}
}
customerized convert from field type to DB field's type的更多相关文章
- 使用elasticsearch启动项目报错failed to load elasticsearch nodes 。。。。。No type specified for field [name]
failed to load elasticsearch nodes .....No type specified for field [name]翻译: 加载ElasticSearch节点失败... ...
- JAVA错误提示:The operation is not applicable to the current selection.Select a field which is not declared as type variable or a type that declares such fields.
平时没怎么注意,今天用Eclipse自动生成Set Get方法时提示错误,错误信息如下: The operation is not applicable to the current selectio ...
- Failed to convert from type [java.lang.String] to type [java.util.Date] for value '2020-02-06'; nested exception is java.lang.IllegalArgumentException]解决
今天做springbook项目前端输入日期传到数据库保存报了一下错误 Whitelabel Error Page This application has no explicit mapping fo ...
- JAVA反射系列之Field,java.lang.reflect.Field使用获取方法
JAVA反射系列之Field,java.lang.reflect.Field使用获取方法. 转载https://my.oschina.net/u/1407116/blog/209383 摘要 ja ...
- 【spring boot】spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [java.util.Date]
spring boot 前台GET请求,传递时间类型的字符串,后台无法解析,报错:Failed to convert from type [java.lang.String] to type [jav ...
- Jpa自定义查询报错(Failed to convert from type [java.lang.Object[]] to type)
Jpa自定义查询报错 问题背景 今天遇到一个奇怪的报错"Failed to convert from type [java.lang.Object[]] to type",这个报错 ...
- [Antd-vue] Warning: You cannot set a form field before rendering a field associated with the value.
在用ant-design-vue的框架中,使用到了这种场景,就是点击编辑按钮,弹出modal模态框,渲染modal模态框中的form表单页面,并给表单赋值,但是在给表单赋值的时候,总是会报错. 错误提 ...
- (转)织梦dedecms模板。如何让type='image'和不带type='image'的文章同时出现在列表里。
“节日歌圩”栏目是有内容的,但是文章没有缩略图所以没有在频道首页显示出来,我现在想要有缩略图的文章自然显示,没有缩略图的文章也能出现标题列表(依然按照一行4个标题,可以用一张“无缩略图”的图片来代替缩 ...
- No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, org.springframework.boot.logging.LogLevel>]
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...
随机推荐
- OpenStack的Resize和冷迁移代码解析及改进
原文:http://www.hengtianyun.com/download-show-id-79.html OpenStack的Resize(升级)功能,我们可以改变虚拟机的CPU核数.内存及磁盘大 ...
- Linux下tar.xz结尾的文件的解压方法
$xz -d ***.tar.xz $tar -xvf ***.tar 可以看到这个压缩包也是两层压缩,外面是xz压缩方式,里层是tar压缩方式.
- workstack windows to openstack
https://www.mirantis.com/openstack-portal/express-openstack-portal/migrating-from-vmware-for-windows ...
- Servlet学习笔记(1)--第一个servlet&&三种状态对象(cookie,session,application)&&Servlet的生命周期
servlet的404错误困扰了两天,各种方法都试过了,翻书逛论坛终于把问题解决了,写此博客来纪念自己的第一个servlet经历. 下面我会将自己的编写第一个servlet的详细过程提供给初学者,大神 ...
- JDBC学习笔记(5)——利用反射及JDBC元数据编写通用的查询方法
JDBC元数据 1)DatabaseMetaData /** * 了解即可:DatabaseMetaData是描述数据库的元数据对象 * 可以由Connection得到 */ 具体的应用代码: @Te ...
- ocp 1Z0-043 131-205题解析
131. Which three methods can you use to run an Automatic Database Diagnostic Monitor (ADDM) analysis ...
- 安装Sublime Text 2插件的方法
1.直接安装 安装Sublime text 2插件很方便,可以直接下载安装包解压缩到Packages目录(菜单->preferences->packages). 2.使用Package C ...
- PDB符号文件信息
一.前言 这个方法是通过网上的一些方式自己学习枚举PDB文件信息. 二.代码实现 首先枚举驱动文件,这里用psapi库 #include "psapi.h" #pragma com ...
- Python 3.2: 使用pymysql连接Mysql
在python 3.2 中连接MYSQL的方式有很多种,例如使用mysqldb,pymysql.本文主要介绍使用Pymysql连接MYSQL的步骤 1 安装pymysql · ...
- 11道php面试题
贡献11道php面试题及解决方法,跟大家总结一下曾经遇到的部分面试题.希望可以给大家得到帮助. 1. 什么事面向对象?主要特征是什么? 面象对象是把自然界的物体和概念直接映射到程序界的一种比较优雅的手 ...