Remove the Temporal annotation for some java.sql attributes

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:

For 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.