-->
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: Ids in base and sub-classes
PostPosted: Fri Mar 24, 2006 10:35 am 
Newbie

Joined: Fri Mar 24, 2006 10:27 am
Posts: 1
Hibernate version: 3.1.2 (Annotations 3.1beta8)

I was wondering whether anyone knows whether it is at all possible to create different ids in both a base and subclass. Obviously both ids are distinct and independently maintained. I have:

@Entity
@TableGenerator (...)
@Table(name="...")
@Inheritance(strategy = InheritanceType.JOINED)
public class BaseClass {
private int id;
...
@Id @GeneratedValue(strategy=GenerationType.TABLE, generator="...")
public int getId() {
return id;
}
}

@Entity
@TableGenerator (...)
@Table(name="...")
public class SubClass extends BaseClass {
private int anotherId;
...
@Id @GeneratedValue(strategy=GenerationType.TABLE, generator="...")
public int getAnotherId() {
return anotherId;
}
}

but when I run this I get:

org.hibernate.AnnotationException: Unable to define/override @Id(s) on a subclass: some.package.SubClass

Reason why I need this is not by design but rather that I'm mapping to existing data and this is how it was designed and organised.

I'd be grateful for any pointers!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Mar 25, 2006 9:51 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
to make it short, no this is not possible

_________________
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.