views:

36

answers:

2

Every example I have found uses @Id, but when I try to write my code, many of the annotations that I'm used to are gone, there are annotatoins like @Index, and the @Entity parameters have changed. I've looked through the Hibernate documentation, and can't find anything talking about changing all of their annotations, so am I looking at a bogus version?

Even @Column() with a name is gone, this is extremely confusing, I'm using Hibernate 3, but I find it hard to believe they went through and broke EVERY annotation that they used to support.

I downloaded the most recent version of Hibernate3.jar, that's all I've included, looking through the JAR I see the annotations packages

import org.hibernate.annotations.Entity;
import org.hibernate.annotations.Table;
A: 

No, the annotations haven't changed.

It's hard to us for know if you are looking at a bogus version without knowing what is on your classpath.

Are you sure that hibernate-annotations is on your classpath? As well as the JAR containing the javax.persistence classes (such as hibernate-jpa-2.0-api-1.0.0.Final.jar)?

matt b
+1  A: 

I think a wrongly defined class path on your side is more likely than a bogus version. And without more details about the version of Hibernate you're using, the JARs you have on the class path, I don't know what to add.

Update: I'd suggest to use JPA annotations over Hibernate annotations. Here are the dependencies I'm using with the latest version of Hibernate Entity Manager:

org.hibernate:hibernate-entitymanager:jar:3.5.3-Final:compile
+- org.hibernate:hibernate-core:jar:3.5.3-Final:compile
|  +- antlr:antlr:jar:2.7.6:compile
|  +- commons-collections:commons-collections:jar:3.2:compile
|  +- dom4j:dom4j:jar:1.6.1:compile
|  |  \- xml-apis:xml-apis:jar:1.0.b2:compile
|  \- javax.transaction:jta:jar:1.1:compile
+- org.hibernate:hibernate-annotations:jar:3.5.3-Final:compile
|  \- org.hibernate:hibernate-commons-annotations:jar:3.2.0.Final:compile
+- cglib:cglib:jar:2.2:compile
|  \- asm:asm:jar:3.1:compile
+- javassist:javassist:jar:3.9.0.GA:compile
\- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.0.Final:compile
Pascal Thivent
I downloaded the most recent version of Hibernate3.jar, that's all I've included, looking through the JAR I see the annotations packages
walnutmon
JPA annotations are in the javax.persistence package. You'll need to include more than just the hibernate JAR. Refer to http://docs.jboss.org/hibernate/stable/annotations/reference/en/html/ch01.html
matt b
@matt b: edited* Ok, with JPA now all annoations are correct, if you add that to your answer I'll accept it, didn't realize I needed JPA if I wasn't using the JPA abstraction. Thanks
walnutmon
there are standard JPA annotations (under the javax.persistence namespace) and custom Hibernate extensions as well. The "Hibernate Annotations" project refers to both the latter but also the Hibernate implementation of the JPA EntityManager
matt b