skyman skyman - 2 years ago 145
Java Question

Spring JPA, Eclipselink and Auditing

I have been configuring Spring auditing for my entity classes. Using annotations, I have something like this:

private Date createdDate

private User createdBy

The createdBy field is being set correctly, however persisting the object fails with a null createdDate. I am guessing that this may be related to type conversion for Eclipselink?

Answer Source

@Temporal annotation is available since the release of JPA 1.0. @Temporal solves the one of the major issue of converting the date and time values from Java object to compatible database type and retrieving back to the application.

@Column(name = "XDATE") @Temporal(TemporalType.DATETIME) private Date xDate; //java.util.Date

I hope this will resolve your problem. For more info please refer this link

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download