-->
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.  [ 7 posts ] 
Author Message
 Post subject: Where are those classess in the annotation package?
PostPosted: Tue Feb 17, 2009 5:43 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
I am updating a Spring-Hibernate web application with the Hibernate annotation. For some reason, I run into complains on @Id for can't resolved for a type, @Table(name="comuser") for undefined "name" etc. although I have hibernate-annotations.jar, hibernate-comons-annotations.jar and ejb3-persistence.jar and the Hibernate3 core as mentioned in the document.

What I am missing here?

Hibernate version:
3.3.1 GA


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 6:13 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
Are you importing the correct classes? There is for example both a @org.hibernate.annotations.Table and a @javax.persistence.Table. Only the @javax.persistence.Table has a "name" attribute.

You can find more information here: http://www.hibernate.org/hib_docs/annot ... ty-hibspec


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 17, 2009 7:29 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
nordborg wrote:
Are you importing the correct classes? There is for example both a @org.hibernate.annotations.Table and a @javax.persistence.Table. Only the @javax.persistence.Table has a "name" attribute.

You can find more information here: http://www.hibernate.org/hib_docs/annot ... ty-hibspec


I use Eclipse with the all hibernate-annotations.jar, hibernate-comons-annotations.jar and hibernate3.jar in the build path. So what you said is that @Id and @Table(name="..") are in the javax.persistence package, but not in Hibernate annotation package.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2009 3:21 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
It's fine that you have the JAR files on the build path, but which classes are you importing in your code? Eg.

Code:
package my.package;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name="...")
public class MyClass
{
...
}


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2009 7:44 am 
Expert
Expert

Joined: Thu Jan 08, 2009 6:16 am
Posts: 661
Location: Germany
wei725 wrote:
I use Eclipse with the all hibernate-annotations.jar, hibernate-comons-annotations.jar and hibernate3.jar in the build path. So what you said is that @Id and @Table(name="..") are in the javax.persistence package, but not in Hibernate annotation package.

You also need to include ejb3-persistence.jar to your eclipse build path, so that the right classes (as nordborg said) are imported.

And right, javax.persistence is not part of hibernate-annotations.

_________________
-----------------
Need advanced help? http://www.viada.eu


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2009 1:51 pm 
Regular
Regular

Joined: Tue Feb 17, 2009 3:36 pm
Posts: 78
Thanks folks.

I thought the annotations were a part of Hibernate one. They are not in fact. I still have a complain on this one:
Code:
@Id(generate=GeneratorType.SEQUENCE, generator="SEQ_USER")

for the generate and generator.

I can work around it with a replacement of
Code:
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="SEQ_USER") 


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 18, 2009 3:12 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The last example seems to be identical to the example in the Hibernate docs: http://www.hibernate.org/hib_docs/annot ... identifier

I guess that is how you are supposed to do it. I have never seen the first variant. As far as I know the @Id annotation doesn't support any attributes.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.