views:

1463

answers:

1

Say I have these table in an Oracle database

Person: PersonId <- PK ID (int, from sequence) PersonFirstNameID <-- int PersonLastNameID <-- int PersonSecurityID <-- int

PersonDetails PersonFirstNameID -CompositeKey PersonLastNameID -CompositeKey PersonSecurityID -CompositeKey PersonDetailKey PersonDetailValue PersonDetailRisk

Now I want to model the one to many relation from Person to PersonDetails in NHibernate.

How can I do this? I've tried setting up a component representing the composite Id and feeding this into the one to many via the property ref however this generate SQL with duplicate columns and throws the following: System.ArgumentException: Identifier type mismatch; Found: Expected:

The NHibernate documentation talks only about doing this when the composite Id is the same on both..

Yes... Its not my DB schema, its a legacy DB and access is very limited. :(

A: 

Not quite clear.

For a foreign key relationship to work, the child must reference the primary key of the parent, so the data structure suggests that the primary key of person is FirstNameId/lastNameid/securityid (and hence your best move would be to ignore the personid column).

Is the Person_Id actually the primary key (defined as a PK in the DB), or is the database's version of PERSON primary key actually FirstNameId/lastNameid/securityid ?

Gary