-->
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: mapping problem
PostPosted: Fri May 13, 2005 2:56 am 
Newbie

Joined: Fri May 13, 2005 2:46 am
Posts: 2
Location: Gruitrode, Belgium
I can't map the following table structure in hibernate3 xml.

The contacts table links to the countries table using the CID, not the primary key of the countries table, because the application must be language indepedent. The CID is not unique, so many-to-one doesn't work here.
I know there are better ways of doing this (using an extra table for the translation for example), but I'm stuck with this table structure and have to convert it to a hibernate mapping xml.

Can anybody give me advise please?
Thanks!

Code:
[countries table]
ID   CID   LANGUAGE   COUNTRY
123    5      NL         BelgiĆ«
124    5      EN         Belgium
125    5      FR         Belgique
126    8      NL         Duitsland
127    8      EN         Germany
128    8      FR         l'Allemagne


[contacts table]
ID   NAME      COUNTRY
1   contact1   5
2   contact2   8
3   contact3   8   
4   contact4   8   
5   contact5   5   


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 13, 2005 3:01 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what about dynamic filter? you can pass the language dynamically, thanks to this you should have one (and only one) element in the one-to-many collection if the filter is applied. Then just add a business method (if list.size() = 1 return first element...).

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


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.