-->
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: Translation using composed primary key?
PostPosted: Tue Jun 12, 2007 5:52 am 
Newbie

Joined: Tue Jun 12, 2007 5:33 am
Posts: 1
Hibernate version: NHibernate 1.2

I have a fairly specific issue, but due to my lack of knowledge of NHibernate I don't know if this can be added easily or not. It's a rather difficult issue to implement I think personally due to the database not naturally supporting this structure.

What I have to demonstrate my issue is a Person table and a PersonType and Culture lookup table.

The schema's are as follows:

- Person - PK(ID), FK(PersonTypeID)
- PersonType - PK(ID, FK(CultureID)), Description
- Culture - PK(ID), Description

Thus a PersonType is a composed primary key of ID and CultureID. The culture id is added to allow for easy translation between types depending on the culture of the current logged in user. However I cannot create a foreign key from Person to PersonType due to the fact that I don't have a culture id available until runtime, thus this needs to be supplied as a parameter at runtime.

How can it be achieved in NHibernate so that I can create an NHibernate query that will fetch me the correct translated data for the following example query? Also, what will the mapping file look like?

SELECT * FROM Person
INNER JOIN PersonType ON Person.PersonTypeID = PersonType.ID
INNER JOIN Culture ON PersonType.CultureID = Culture.ID
WHERE Culture.CultureID = @cultureID

Thanks in advance for any suggestions/help.

Lexx


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.