-->
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.  [ 5 posts ] 
Author Message
 Post subject: Id in Superclass
PostPosted: Wed Jun 15, 2005 2:53 am 
Newbie

Joined: Fri Oct 03, 2003 10:46 pm
Posts: 8
Hibernate version: 3.0.5

Mapping documents:Annotations

Hello

I'm using annotations for Hibernate and found a problem with my test application. I have a superclass containing id and version property:

Code:
public abstract class BaseObject implements Serializable {
 
  private Integer id;
  private int version;

  @Id(generate = GeneratorType.AUTO)
  public Integer getId() {    return id;  }

  protected void setId(final Integer id) {    this.id = id;  }

  @Version
  @Column(nullable = false)
  public int getVersion() {    return version;  }

  public void setVersion(final int version) {    this.version = version;  }

}


Then i created a entity class :

Code:
@Entity
public class Category extends BaseObject {

  private String colour;

  @Column(nullable = false, length = 6)
  public String getColour() {    return this.colour;  }

  public void setColour(String colour) {    this.colour = colour;  }
}



This works with Hibernate Annotations 3.0 beta 2 Preview. But it no longer works with the newest source from cvs (June 15, 2005). This error message appears:

org.hibernate.AnnotationException: No identifier specified for entity: Category at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:494)

Any ideas what i'm doing wrong?
Code:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 16, 2005 9:00 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
We change our strategy. The spec now mak this area more clear.
Basically you have to tag your superclass as @EmbeddedSuperclass

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 2:02 am 
Newbie

Joined: Fri Oct 03, 2003 10:46 pm
Posts: 8
Thanks for your answer. I changed my superclass and added the @EmbeddedSuperclass tag. Unfortunately i still get the same error message:

Code:
org.hibernate.AnnotationException: No identifier specified for entity: Category
   at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:496)
   at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:174)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:975)



Code:
@EmbeddedSuperclass
public abstract class BaseObject implements Serializable {
 
  protected Integer id;
  protected int version;

  @Id(generate = GeneratorType.AUTO)
  public Integer getId() {    return id;  }

  protected void setId(final Integer id) {    this.id = id;  }

  @Version
  @Column(nullable = false)
  public int getVersion() {    return version;  }

  public void setVersion(final int version) {    this.version = version;  }

}


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 5:08 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
don't forget to declare your superclass as a annotated class (in the cfg.xml for example)

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 17, 2005 5:31 am 
Newbie

Joined: Fri Oct 03, 2003 10:46 pm
Posts: 8
That solved the problem. Thanks for your help


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