Hi, I will not have a collection of Relations in the Contact entity, instead I will add a method named "Relations" in that entity that delegates to a finder/repository method to return the 'Relation' instances that satisfy your query requirements. I dont think you can directly achieve what your trying using a mapping, I can think of a way to achieve what you want but it would require extra logic on the entities. The finder approach is cleaner and it would probably perform better.
On Thursday, 5 July 2012 16:38:49 UTC+1, Jan Willem van Diermen wrote: > > Not sure how to describe this, and couldn't find anything, so here it is: > > I have 2 entities, "Contact" and "Relation". "Contact" can be a person, a > company, or something else. > "Relation" describes a relationship between two contacts. > > What is the best way to create this? On "Contact", I want a property > "Relations" of type "Relation". > > I was thinking of this example: > > Contact > - Id > - Name > - Relations (one-to-many to "Relation") > > Relation > - Id > - LeftContact (one-to-one to "Contact") > - RightContact (one-to-one to "Contact") > - StartDate > - EndDate (nullable) > > Since the key to the contact could be in either "LeftContact" or > "RightContact", how do I create the "Contact.Relations" property without > having to create properties for each key? > Normally you would simply use the query: *WHERE (Contact.Id = > Relation.LeftContactId OR Contact.Id = Relation.RightContactId)* > * > * > I hope you can understand my question, please let me know if you have any > questions. > Thanks in advance! > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To view this discussion on the web visit https://groups.google.com/d/msg/nhusers/-/ws6DtUIbyI0J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
