-->
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: Mapping several tables to one class
PostPosted: Sun Jul 10, 2005 10:07 am 
Newbie

Joined: Sun Jul 10, 2005 9:58 am
Posts: 1
I know it's possible to map several classes to a single table using
component element, but i want to do the opposite : map several
tables to one class. i know it can be achieved with joined style
inheritance, but i want to join 2 tables that don't map to classes
with inheritance relations. is it possible ?
thanks a lot.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 10, 2005 10:18 am 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
See http://www.hibernate.org/hib_docs/v3/reference/en/html_single/#mapping-declaration-join


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 9:58 am 
Newbie

Joined: Fri Jul 08, 2005 6:26 am
Posts: 4
Location: France, Paris
wouldn t it be much easier to work on a table view?
(or am i completely wrong?)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 10:12 am 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
Quote:
wouldn t it be much easier to work on a table view?


Hibernate is certainly capable of doing so, although if you plan to update your entities (specifically, CREATE UPDATE or DELETE), the view must support this (which depends on your database's capabilities). The documentation states that views (as expected) are transparent to hibernate at the database level, and appear to be tables.

If you have the option of creating a VIEW for your entity, then that may certainly be the option you'll wish to choose. It's really a matter of taste. However, if you don't have the option of creating a VIEW (for whatever reasons), Hibernate can still support your requirements through a join mapping.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jul 11, 2005 10:41 am 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
Your database doesn't have to support materialized views if you can create a trigger to intercept DML to the view and split it up into operations on the view's component tables.


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.