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
|