According to the JPA spec, support is provided for the five temporal types:
java.sql.Date, java.sql.Time, java.sql.Timestamp, java.util.Date, java.util.Calendar.
However, what about GregorianCalendar - this class inherits from java.util.Calendar?
I wrote some test code and Hibernate supports GregorianCalender if the temporal annotation is used at field level.
For example:
@Temporal(TemporalType.DATE)
private GregorianCalendar dateOfBirth = null;
This works.
However, if the annotation is at method level, for example,
@Temporal(TemporalType.DATE)
public GregorianCalendar getDateOfBirth() {
return dateOfBirth;
}
hibernate will throw an annotation exception at start up.
Failed to invoke suite():javax.persistence.PersistenceException: org.hibernate.AnnotationException: @Temporal should be set on a java.util.Date or java.util.Calendar property: Person.dateOfBirth
Is this a bug?
Comments welcomed
|