-->
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: Problem with Hibernate Annotations and Joined subclasses
PostPosted: Tue Oct 04, 2005 6:49 am 
Newbie

Joined: Tue Oct 04, 2005 6:25 am
Posts: 1
Location: Russian Federation
Hibernate version: 3.1beta3

Hibernate Annotations version: 3.1beta5

Full stack trace of any exception that occurs:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: ru.siteforge.model.Account
org.hibernate.AnnotationException: No identifier specified for entity: ru.siteforge.model.Account
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)
...


Name and version of the database: MySQL 4.0.24


Code:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "sf_persistent_object")
abstract class PersistentObject implements Serializable
{
   private static final long serialVersionUID = -3555198930641746803L;

   private long id;
   private Calendar lastModifiedDate;
   private Calendar creationDate;
   private Account lastChanger;
   private Account creator;

   @Id(generate = GeneratorType.TABLE, generator = "obj_id_gen")
   @Column(name = "id")
   public long getId()
   {
      return id;
   }

   @Column(name = "last_modified_date", nullable = false)
   public Calendar getLastModifiedDate()
   {
      return lastModifiedDate;
   }

   @Column(name = "creation_date", nullable = false)
   public Calendar getCreationDate()
   {
      return creationDate;
   }

   @ManyToOne(cascade = CascadeType.ALL)
   @JoinColumn(name = "fk_last_changer_id", nullable = false)
   public Account getLastChanger()
   {
      return lastChanger;
   }

   @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
   @JoinColumn(name = "fk_creator_id", nullable = false)
   public Account getCreator()
   {
      return creator;
   }

   public void setId(long id)
   {
      this.id = id;
   }

   public void setLastModifiedDate(Calendar lastModified)
   {
      this.lastModifiedDate = lastModified;
   }

   public void setCreationDate(Calendar creationDate)
   {
      this.creationDate = creationDate;
   }

   public void setCreator(Account owner)
   {
      this.creator = owner;
   }

   public void setLastChanger(Account lastChanger)
   {
      this.lastChanger = lastChanger;
   }

}



Code:
@Entity(access = AccessType.PROPERTY)
@PrimaryKeyJoinColumn(name="fk_persistent_object_id")
@Table(name = "sf_account")
@TableGenerator(name = "obj_id_gen", tableName = "GEN_TABLE", pkColumnValue = "global_object_id", allocationSize = 1)
@GeneratedIdTable(
   name="GEN_TABLE",
   table = @Table(name="sf_hibernate_sequences")
)
public class Account extends PersistentObject
{
   private static final long serialVersionUID = -9009838260646199450L;
   
   private String username;
   private String password;
   private String email;
   
   public Account()
   {
      super();
   }
   
   public Account(String email, String password)
   {
      this.email = email;
      this.password = password;
   }

   @Basic
   @Column(name = "email")
   public String getEmail()
   {
      return email;
   }
   public void setEmail(String email)
   {
      this.email = email;
   }
   @Basic
   @Column(name = "username")
   public String getUsername()
   {
      return username;
   }

   public void setUsername(String username)
   {
      this.username = username;
   }
   @Basic
   @Column(name="password")
   public String getPassword()
   {
      return password;
   }
   public void setPassword(String password)
   {
      this.password = password;
   }
}


When I specified identifier in Account class all start working, but inheritance not and I have following sql:
Hibernate: select account0_.id as id0_0_, account0_.password as password0_0_, account0_.username as username0_0_, account0_.email as email0_0_ from sf_account account0_ where account0_.id=?
Hibernate: insert into sf_account (password, username, email, id) values (?, ?, ?, ?)
What I doing wrong?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 05, 2005 9:21 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
You're not adding PersistentObject in your configuration IMO.

_________________
Emmanuel


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.