-->
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: How To map inheritance with abstract base, multiple leafs
PostPosted: Wed Sep 28, 2005 1:08 pm 
Newbie

Joined: Wed Sep 28, 2005 1:02 pm
Posts: 4
Hi,
I try to find a simple way to create the following relations:

User (abstract class) stores fields username, etc
Operator extends User (entity)
Client extends User (entity)

I want Operator and Client to be entities with different tables,

the inheritance examples presented in the doc are not working in this case because I also have many to many relations in the Operator and Client classes and an error occurs at deployment (many.. relations not supported with inherintance)

thanks a lot


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 2:05 pm 
Beginner
Beginner

Joined: Mon Mar 28, 2005 12:58 pm
Posts: 27
Have you tried making the User class an @EmbeddableSuperclass ? This will actually make Operator and Client free from possible inheritance issues. Also it will be more beneficial to you if you post what versions of hibernate you are using, actual code and actual error messages. :)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 3:53 pm 
Newbie

Joined: Wed Sep 28, 2005 1:02 pm
Posts: 4
I choosed another option:
I used
@Inheritance(strategy=InheritanceType.JOINED)

and also created the base class as a table,

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class User implements Serializable ...
... defined ID ...

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Operator extends User...
... defined ID ...

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Client extends User ...
... defined ID ...

this will generate 3 tables and the relations between them are managed using the matching of ids (in Operator and Client tables I will not have sequencial keys... but sets of keys, ex operator:1,3,10... client:2,4..9,..., user:1,2,...10


Top
 Profile  
 
 Post subject: mistake ...
PostPosted: Wed Sep 28, 2005 4:07 pm 
Newbie

Joined: Wed Sep 28, 2005 1:02 pm
Posts: 4
MISTAKE:

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class User implements Serializable ...
... defined ID ...

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Operator extends User...

@Entity
@Inheritance(strategy=InheritanceType.JOINED)
public class Client extends User ...

THE ID's are not redefined into the child classes...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 28, 2005 4:16 pm 
Newbie

Joined: Wed Sep 28, 2005 1:02 pm
Posts: 4
anyway, your idea was very good, I'll use that annotation in other stuff. thanks a lot

athu9999 wrote:
Have you tried making the User class an @EmbeddableSuperclass ? This will actually make Operator and Client free from possible inheritance issues. Also it will be more beneficial to you if you post what versions of hibernate you are using, actual code and actual error messages. :)


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.