I am new to NHIBERNATE. I have got a scenerio in which I have got two Domain Objects called
1. Message
2. Queue
and 3 Database tables called
1. Message
2. Queue
3. QueueMessage
As you would have guessed, I use QueueMessage to associate a Message to a Queue.
The QueueMessage table has got compositeId (MessageId,QueueId) and a field called Status.
In the Domain model Status field belongs to Message Class and it could be null if the message is not associated with any queue. But when the message is associated with a queue I need to populate the Doman.Message object from two database tables, similarly I need to update/save it in two tables (Message,QueueMessage).
I understand that in NHibernate 2.0 I could make use of <Join Table> element to join two tables but how could I use a composite key ?
My second question is that what is the best way to handle composite keys. Should I have a composite key or instead I replace it with an identity column ?
Your help is much appreciated.
Cheers,
Syed Askari
|