-->
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: Table is created for abstract class
PostPosted: Wed May 02, 2007 2:55 pm 
Regular
Regular

Joined: Wed May 02, 2007 2:42 pm
Posts: 101
Hey,

I create an abstract class called - Profile
the class mark as enitity,because i need to have a relation of one to one between users
also i added table per class policy to the class


the class has an id, one to one relation with itself.

I also created a class called UserProfile that extends Profile.

i am using Jboss and when i deploy the jar i saw that it created two tables:
1. Profile
2. UserProfile that also contained the fileds that were declared in the Profile entity.

Can someone explain how to avoid from creation of the Profile table?
Do you recommand to use in table per class strategy in scenario like this?

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 03, 2007 3:25 am 
Senior
Senior

Joined: Tue Jul 25, 2006 9:05 am
Posts: 163
Location: Stuttgart/Karlsruhe, Germany
Hi,

If you have marked the class @Entity, i table will automatically be created on deployment in JBoss (assuming you have set the hbm2ddl task to create or update), to stop this table creation you need to remove @Entity, but this will break the OneToOne relationship.

With inheritance you have a few options (3), I personally would not use a table per concrete class strategy as it creates an unmormalised DB model (redundant data). This leaves 2 options, 1) single table for the entire hierarchy, or 2) table per subclass, my own personal preference is for the table per subclass (prefer the DB schema created).

Cheers,

Andy

_________________
Rules are only there to be broken


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.