wood burning stoves 2.0*
The moose likes JBoss/WildFly and the fly likes Error - org.hibernate.AnnotationException: No identifier specified for entity Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Error - org.hibernate.AnnotationException: No identifier specified for entity" Watch "Error - org.hibernate.AnnotationException: No identifier specified for entity" New topic
Author

Error - org.hibernate.AnnotationException: No identifier specified for entity

subir rastogi
Greenhorn

Joined: Apr 11, 2006
Posts: 18
Hi,
I have example in JPA and getting following error during deploying the ear to JBOSS.
org.hibernate.AnnotationException: No identifier specified for entity: com.entity.Cabin
Here is the Cabin class -


Please advice on what could be the issue here?

thanks.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Try to use the annotations on the get methods of your entity.


Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
subir rastogi
Greenhorn

Joined: Apr 11, 2006
Posts: 18
Thanks Remko, using annotations on the get methods solved the problem..

I am learing JPA so its a requirement that annotations should be used on getters only?

Thanks.
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Yes it is, but you have already discovered that.

Also mostly I do the getter above the setter.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9937
    
159

subir rastogi wrote:
I am learing JPA so its a requirement that annotations should be used on getters only?



Getters or fields. Note that you can't mix and match them though - i.e. you can't have an entity with some fields annotated and some getters annotated for JPA.


[My Blog] [JavaRanch Journal]
subir rastogi
Greenhorn

Joined: Apr 11, 2006
Posts: 18
thanks Jaikiran and Remko for the clarification.
babu joy
Greenhorn

Joined: May 30, 2011
Posts: 1
The error also comes if the class doesn't have an @Id attribute
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error - org.hibernate.AnnotationException: No identifier specified for entity
 
Similar Threads
JPA Query
Help ...Cabin.java:3: package javax.persistence does not exist
JPA using Hibernate - Entity Manager doubts
Cant deploy the entity bean
TestEJB not bound