-->
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.  [ 2 posts ] 
Author Message
 Post subject: org.hibernate.AnnotationException: No identifier specified f
PostPosted: Tue Oct 04, 2005 3:49 am 
Regular
Regular

Joined: Tue Nov 04, 2003 12:37 pm
Posts: 57
hello,

When I tried inheritance with Hibernate3 annotation, it raised the following errors, what can I do ?


I use Hibernate3.1-beta3 and hibernate-3.1-annotation-beta5


Eric



Code:
package mo.kudocs.framework.bean;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.EmbeddableSuperclass;
import javax.persistence.Entity;
import javax.persistence.GeneratorType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Transient;


@EmbeddableSuperclass
public class AbstractObject implements Serializable {
   public static final long serialVersionUID = 1L;
   
   @Id(generate=GeneratorType.NONE)
   @Column(updatable = false)
   protected long id;
   
   @Column
   protected Date createDate = new Date();
   
   @Column
   protected Date updateDate = new Date();
   
   /**
    *
    */
   public AbstractObject() {
      super();
   }
   
   @Transient
   public String getIndexText() {
      return id + " " +  createDate + " " + updateDate;
   }
   

   @Transient
   public String toString() {
      StringBuffer buf = new StringBuffer();
      buf.append("create date: " + createDate);
      buf.append(", update date: " + updateDate);
      
      return buf.toString();
   }

   
   /**
    * @return Returns the createDate.
    */
   public Date getCreateDate() {
      return this.createDate;
   }

   
   /**
    * @param createDate The createDate to set.
    */
   public void setCreateDate(Date createDate) {
      this.createDate = createDate;
   }

   
   /**
    * @return Returns the updateDate.
    */
   public Date getUpdateDate() {
      return this.updateDate;
   }

   
   /**
    * @param updateDate The updateDate to set.
    */
   public void setUpdateDate(Date updateDate) {
      this.updateDate = updateDate;
   }

   
   /**
    * @return Returns the id.
    */
   public long getId() {
      return this.id;
   }

   
   /**
    * @param id The id to set.
    */
   public void setId(long id) {
      this.id = id;
   }

   

}





Code:

package mo.kudocs.framework.bean;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.Transient;


@Entity
@Table (name = "SYS_COUNTER")
@NamedQueries ( {
      @NamedQuery (name = "syscounter.findAll", queryString = "select sc from SystemCounter sc"),
      @NamedQuery (name = "syscounter.findByName", queryString = "select sc from SystemCounter sc where sc.name = :name")
})
public class SystemCounter extends AbstractObject {

   public static final long serialVersionUID = 1L;

   
   protected String name;

   protected long value;

   /**
    *
    */
   public SystemCounter() {
      super();
   }

   /**
    * @return Returns the name.
    */
   @PrimaryKeyJoinColumn
   @Column (nullable = false)
   public String getName() {
      return this.name;
   }

   /**
    * @param name
    *           The name to set.
    */
   public void setName(String name) {
      this.name = name;
   }

   /**
    * @return Returns the value.
    */
   @Column (nullable = false)
   public long getValue() {
      return this.value;
   }

   /**
    * @param value
    *           The value to set.
    */
   public void setValue(long value) {
      this.value = value;
   }

   @Transient
   public String getIndexText() {
      return name + " " + value;
   }

   @Transient
   public String toString() {
      StringBuffer buf = new StringBuffer();
      buf.append("name=" + name + ", value=" + value);

      return buf.toString();
   }

}



Code:
SEVERE: Building SessionFactory failed.
org.hibernate.AnnotationException: No identifier specified for entity: mo.kudocs.framework.bean.SystemCounter
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:645)
   at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:256)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:191)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1120)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 5:02 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Either all property annotations are on the fields (AccessType.FIELD) or they are on the getter methods (default).


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