【发布时间】:2020-10-09 03:57:24
【问题描述】:
我在将 Time 正确插入 PostgreSQL 数据库时遇到问题。 使用 SpringBoot,使用 JPARepository 和 hibernate 制作 web 应用程序。 使用这种方言:
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect
我有一堂课:
@Entity
public class Class {
//other stuff
@Column(name = "date_and_time")
private LocalDateTime dateAndTime;
我需要一些测试数据,当我使用这个脚本启动我的应用程序时:
insert into class(date_and_time) values (DATE('2020-06-10 18:43:20');
我的数据库中的结果如下所示 2020-06-10 00:00:00
有什么方法可以在我的数据库中正确插入时间?
【问题讨论】:
-
您是否尝试将其标记为
@Temporal(TIMESTAMP)?
标签: java postgresql spring-boot hibernate localdatetime