-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: GregorianCalender as a Temporal type
PostPosted: Fri Jan 26, 2007 12:50 pm 
Senior
Senior

Joined: Mon Jul 24, 2006 8:43 am
Posts: 160
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


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 02, 2007 11:30 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You probably left your @id annotation on field

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.