-->
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.  [ 3 posts ] 
Author Message
 Post subject: Trying to map an object with multiple joins/many-to-one
PostPosted: Thu Feb 12, 2009 2:25 pm 
Newbie

Joined: Thu Feb 12, 2009 2:00 pm
Posts: 2
Hibernate version: 3.2.1

Hi all,

I'm trying to map an Object to the following tables. I've changed the name in order to make it easier to understand.

I can hardly change the DB schema (the tables map files that are directly loaded in no specific order)

* Table1

* Table2
(simple 1 to 1 join with table 1)
Table2.PK = Table1.a_Table1_column (which is not the PK)

Table2 has two columns: Table2.Table3_Leg1Id and Table2.Table3_Leg2Id

* Table3
Table3 is joined twice in the query
Table3.Table3_PK = Table2.Table3_Leg1Id
and
Table3.a_Table3_column = Table2.Table3_Leg2Id

* Table4
Table4 joins with Table3
Table4.PK = Table3.Table4_Id

The object that needs to be mapped is as follows:
* contains all the data from table1
* contains 1 Table2 Object (which only contains the values from Table2)
* contains 2 Table4 Objects

Now, I don't seem to be able to write the correct XML for this mapping. In fact, in the first place, I didn't have the Table3 so I cheated a bit and created an ExtendedTable2 object that contained also the Table4 objects.

But with this new table, and the fact that I do have an other mapping (with Tables 1 -> 2 -> (two links) 5) in this object, I'd like to create something cleaner.

So my question is can this be done?

For the moment, the only solution I could come with was to create views (I only do select queries).

Thanks for your help.

Cheers

Adj


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 12, 2009 11:00 pm 
Senior
Senior

Joined: Tue Aug 01, 2006 9:24 pm
Posts: 120
Quote:
So my question is can this be done?


Yes


Top
 Profile  
 
 Post subject: As we say here, "fool me once... fool me once"
PostPosted: Fri Feb 13, 2009 4:08 am 
Newbie

Joined: Thu Feb 12, 2009 2:00 pm
Posts: 2
ethnarch wrote:
Quote:
So my question is can this be done?


Yes


Good.

But, this answer raises an other question: can it be done... without using a subselect ?

I mean I don't want to mix SQL with Hibernate mapping, I prefer to use either one or the other but not both.

Adj


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.