NHibernate - Composite-Id by relation - where parent ID is not the same composite
Let's say I have this 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 a one to many relationship from Person to PersonDetails in NHibernate.
How can i do this? I tried to set up a component representing a composite identifier and pass it to one of many via a ref property, however this generates SQL with duplicate columns and throws the following: System.ArgumentException: identifier type mismatch; Found: Expected:
The NHibernate documentation only talks about this when the composite id is the same on both.
Yes ... Not my DB schema, its a legacy DB and very limited access.
Not quite clear.
For a foreign key to work relationship, the child must refer to the parent's primary key, so the data structure assumes that the person's primary key is FirstNameId / lastNameid / securityid (and hence your best move would be to ignore the personid column).
Is Person_Id actually the primary key (defined as a PK in the DB) or is the PERSON primary key database actually FirstNameId / lastNameid / securityid?
source to share