-->
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: TablePerClass with SingleTable
PostPosted: Sun Apr 07, 2013 10:38 pm 
Newbie

Joined: Sat Apr 02, 2011 1:06 pm
Posts: 11
Hello everyone,

I want to implement the following structure: entity A, which declares InheritanceType.TABLE_PER_CLASS. Then entity B extends entity A and declares InheritanceType.SINGLE_TABLE. The reason is - I want to have a base Entity for all my entities. And I want all my children entities, like User, Product, Address, etc to be in their own table. But I also want MyProduct, HisProduct, YourProduct to be in the same table as Product.

- I can't use MappedSuperclass on entity A because then I can't have *ToMany relations to my base entity A.
- I can't declare entity A as InheritanceType.SINGLE_TABLE because then it only creates 1 table - the table for entity A.
- I can't declare entity B as InheritanceType.JOINED, because then I don't have the pk and id, and some other common fields in the same table, so that when I do a OneToMany and I specify mappedBy="PK" it doesn't find it.

What is the right approach here?

Thanks.


Top
 Profile  
 
 Post subject: Re: TablePerClass with SingleTable
PostPosted: Thu Apr 11, 2013 5:29 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
Quote:
entity A, which declares InheritanceType.TABLE_PER_CLASS. Then entity B extends entity A and declares InheritanceType.SINGLE_TABLE.


This above seems to be the right approach for your requirements.
Did this strategy mix don't work for you as excpected ?


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.