views:

372

answers:

0

People, I have a horrible legacy DB that i have to map in nHibernate, that im not allowed to change.

There is a horrible tree structure called FaultCodes with these fields:

  • ID int
  • eventID int
  • treeID int (unique per eventID)
  • parentTreeID int

ID is the PK, its used by other tables to join to this one. Problem is, the parent/child relation doesnt use this ID, nooooooo, that would be too easy.

A child FaultCode is linked to its parent using a composite foregin key, (parentTreeID, eventID), because there is in effet a second, composite primary key(eventID,TreeID) on FaultCode, as well as the actual ID primary key.

Is this totally impossible to map? Its a pretty messed up schema. Any idea how to do it? :)