【发布时间】:2020-06-27 07:39:43
【问题描述】:
我的模型扩展了这个 AuditModel
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(
value = {"createdAt", "updatedAt"},
allowGetters = true
)
public abstract class AuditModel implements Serializable {
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "created_at", nullable = false, updatable = false)
@CreatedDate
private Date createdAt;
@Temporal(TemporalType.TIMESTAMP)
@Column(name = "updated_at", nullable = false)
@LastModifiedDate
private Date updatedAt;
//getters and setters
}
我已将以下行添加到 application.properties
spring.jpa.properties.hibernate.jdbc.time_zone=UTC
但我希望数据库条目中的时间为 UTC+05:30。该怎么做?
谢谢
【问题讨论】:
标签: spring hibernate jpa spring-data-jpa audit