-->
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: One entity map with two tables
PostPosted: Mon Nov 05, 2007 2:28 am 
Newbie

Joined: Mon Nov 05, 2007 12:13 am
Posts: 1
I would like to ask is it feasible to define one single entity to map with two tables. If yes, is it a good approach to implement in this way? Thx


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 05, 2007 3:43 am 
Expert
Expert

Joined: Thu Jul 05, 2007 9:38 am
Posts: 287
Yes you can:

http://www.hibernate.org/hib_docs/annot ... e/#d0e1717

Quote:
You can map a single entity bean to several tables using the @SecondaryTable or @SecondaryTables class level annotations. To express that a column is in a particular table, use the table parameter of @Column or @JoinColumn.

Is this a good aproach? Well it really depends what you are aproaching.

Obviously this kind of entity will cause some extra DML and Joins. But if you have a sound reason to split your data in two tables this is the way to go.l


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.