-->
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.  [ 1 post ] 
Author Message
 Post subject: Strange many-to-one case
PostPosted: Fri Oct 20, 2006 12:29 pm 
Newbie

Joined: Fri Oct 20, 2006 12:15 pm
Posts: 1
Apologies if this is obvious from the mapping guide, but I can't work it out.

I am in the process of manually creating a mapping for a legacy database and existing Dto object.

The table structure is as follows: a transactional table PERSON has a many-to-one aggregational relationship to COUNTRY, indicating the country in which they live. The foreign key COUNTRY_CODE exists on the PERSON table.

Unfortunately, the PersonDto also contains the country description, i.e. it aggregates an additional column from COUNTRY, which is ignored on insert and update.

The existing Dao, which uses hand-crafted SQL, simply uses a LEFT OUTER JOIN to get this, and then populates the PersonDto from the result set.

How can I map this with Hibernate? IIUC,a <join> is only for extension composed data, i.e. both tables must have the same primary key. It's like I want to specify a many-to-one, but not a class mapping, instead a table mapping where I aggregate a column as a property into the class.

I could use the 'formula="arbitrary SQL expression"' on the property definition, but that will result in multiple queries run, when a left outer join is what is desired.

BTW - I tried to search the forums, but whenever I try to go page 2 onwards of the search results, it tells me no posts matched my query.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.