OpenJPA persists the fields of attributes of type java.sql.Date, java.sql.Time, or
java.sql.Timestamp that have a javax.persistence.Temporal annotation, whereas EclipseLink throws an exception.
This rule scans for the following annotation-attribute combinations where
data does not need to be converted and
the Temporal annotation must be removed to avoid an EclipseLink error:
javax.persistence.Temporal(TemporalType.DATE)
annotation on a java.sql.Date attributejavax.persistence.Temporal(TemporalType.TIME)
annotation on a java.sql.Date attributejavax.persistence.Temporal(TemporalType.DATE)
annotation on a java.sql.Time attributejavax.persistence.Temporal(TemporalType.TIME)
annotation on a java.sql.Time attributejavax.persistence.Temporal(TemporalType.TIMESTAMP)
annotation on a java.sql.Time
javax.persistence.Temporal(TemporalType.TIMESTAMP)
annotation on a java.sql.Timestamp attributeFor cases where a converter class is needed to change the data between the database and the entity object, see the Replace Temporal annotation with a Converter for some java.sql attributes rule.
In the following example, this rule flags the @javax.persistence.Temporal annotation in all cases.
@javax.persistence.Temporal(TemporalType.DATE) private java.sql.Date dateDate; @javax.persistence.Temporal(TemporalType.TIME) private java.sql.Date dateTime; @javax.persistence.Temporal(TemporalType.DATE) private java.sql.Time timeDate; @javax.persistence.Temporal(TemporalType.TIME) private java.sql.Time timeTime; @javax.persistence.Temporal(TemporalType.TIMESTAMP) private java.sql.Time timeTimestamp; @javax.persistence.Temporal(TemporalType.TIMESTAMP) private java.sql.Timestamp timestampTimestamp;
An automated fix will remove the Temporal annotations.
private java.sql.Date dateDate; private java.sql.Date dateTime; private java.sql.Time timeDate; private java.sql.Time timeTime; private java.sql.Time timeTimestamp; private java.sql.Timestamp timestampTimestamp;
For information about this issue and other OpenJPA to EclipseLink migration issues, see the OpenJPA to EclipseLink JPA Migration: Mappings guide.