-->
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.  [ 3 posts ] 
Author Message
 Post subject: Missing an identifier
PostPosted: Wed Jul 06, 2005 6:49 am 
Beginner
Beginner

Joined: Fri Sep 24, 2004 8:18 am
Posts: 24
Hi,

I have the following class :
Code:
@Entity(access = AccessType.PROPERTY)
@Table(name = "Employee")
public class Employee implements Serializable {

    /** identifier field */
    @Id
    @Column(name = "employee_id" ,length = 20)
    private String employeeId = null;

    /** version field */
    @Version
    private int version = 0;
   
    /**
     *
     *
     */
    public Employee() {
    }

    /**
     *
     * @param employeeId
     */
    public Employee(String employeeId) {
        this.employeeId = employeeId;
    }

    /**
     *
     * @return
     */
    public int getVersion() {
       return version;
    }
   
    /**
     *
     * @return
     */
    public String getEmployeeId() {
        return this.employeeId;
    }

    /**
     *
     * @param employeeId
     */
    public void setEmployeeId(String employeeId) {
        this.employeeId = employeeId;
    }

    public String toString() {
        return "EmployeeId (" + getEmployeeId() + ")";
    }

}


But when I compile it, I got this error :
[junit] org.hibernate.AnnotationException: No identifier specified for entity: example.model.Employee
[junit] at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:556)
[junit] at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:174)

I've declared a mapping class in my hibernate config file :
Code:
...
<mapping class="example.model.Employee"/>
...


Anybody know what am I missing here ?

Thanks for any help/suggestion,
nusa.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 7:08 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Read the documentation again: AccessType.PROPERTY = annotations go on the property methods. AccessType.FIELD = annotations go on the fields.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 06, 2005 8:13 am 
Beginner
Beginner

Joined: Fri Sep 24, 2004 8:18 am
Posts: 24
That's it thanks.


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