How to write annotations in JPA so that the field type is date and the data is written with time, minutes and seconds (oracle database)

@javax.persistence.Basic

@javax.persistence.Column(name="PUSH_DATE", columnDefinition="DATE")

@Temporal(value = TemporalType.TIMESTAMPE)

public java.util.Date getPushDate() {return pushDate; }

 

--oracle database

1. Note that it must be java.util.Date or an error will be reported. 

2. columnDefinition="DATE" ensures that the database field is of Date type when it is generated

3. When writing, you can use new java.util.Date(Calendar.getInstance().getTimeInMillis());

 

Then the database field type is Date, and the stored data is hours, minutes and seconds.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326040411&siteId=291194637