-->
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.  [ 6 posts ] 
Author Message
 Post subject: AnnotationException: No identifier specified for entity
PostPosted: Thu Sep 04, 2008 2:33 pm 
Regular
Regular

Joined: Sun Sep 25, 2005 11:35 pm
Posts: 57
I have a very simple class called Role shown below:

Code:
package myapp.security;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.jboss.seam.annotations.security.management.RoleName;

@Entity
public class Role {
    private Integer id;
    private String rolename;

    @Id
    @GeneratedValue
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }

    @RoleName
    public String getRolename() {
        return rolename;
    }
    public void setRolename(String rolename) {
        this.rolename = rolename;
    }
}


When I deploy the EAR on JBoss AS, I get the following exception:

Code:
Problem starting service persistence.units:ear=myapp-1.0-SNAPSHOT.ear,unitName=myappDatabase
org.hibernate.AnnotationException: No identifier specified for entity: myapp.security.Role


Clearly, I have an identifier defined. What am I missing?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 4:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

the mapping looks ok. My guess is a deployment problem. Are you sure there is no older version of this file in the classpath? Sometimes it helps to delete all the tmp data of the server configuration you are working with. Or maybe the ear is packaged the wrong way?

--Hardy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 11, 2008 8:00 am 
Regular
Regular

Joined: Sun Sep 25, 2005 11:35 pm
Posts: 57
Thanks Hardy. I did resolve the issue a few days ago. I think it was deployment related, but I can't remember the exact details. Anyway, no longer a problem.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 30, 2009 10:57 am 
Beginner
Beginner

Joined: Fri Jan 23, 2009 10:34 am
Posts: 25
Location: Switzerland
I got this problem when doing tests with the orm.xml file in JPA mode:

The orm.xml file was setting the default access mode as FIELD, but the since the entity getters are annotated, the persistence provider does not find the identifier (remember: setting the annotation on the property means "field access", while setting the annotation on the getter means "getter access").

I had two possible solutions:
1) remove the default FIELD access in orm.xml
2) move the annotation from the getter to the property


Top
 Profile  
 
 Post subject: Re: AnnotationException: No identifier specified for entity
PostPosted: Thu May 07, 2009 6:05 am 
Regular
Regular

Joined: Thu May 07, 2009 5:56 am
Posts: 94
Location: Toulouse, France
I had this same problem when I used the mapping file (orm.xml)...

I solved this by adding the property "access = FIELD" in the tag "<entity>" of my root class that has the identifier;

Hibernate version tested:
hibernate-annotations-3.4.0
hibernate-commons-annotations-3.1.0
hibernate-core-3.3.0
hibernate-entitymanager-3.4.0

_________________
everything should be made as simple as possible, but not simpler (AE)


Top
 Profile  
 
 Post subject: Re: AnnotationException: No identifier specified for entity
PostPosted: Sat May 30, 2009 5:56 pm 
Newbie

Joined: Thu May 28, 2009 8:52 pm
Posts: 7
I have specified xml-mapping-metadata-complete in orm.xml, which means do not process annotations and defined the complete meta-data in the mapping file.
Also it is not possible for me to use FIELD access.
Moreover, the whole reason for using orm.xml is because I do not want to annotate the classes.

Is there a way I can get this to work in this case w/o annotations and w/o using FIELD access?
BTW, its working with TopLink but fails with hibernate JPA.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 6 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.