mdsrlz wrote:
But when I create a SalesMan there is one Person (1-to-1) assigned and when I create a Customer also there is one Person (1-to-1) assigned to this. In other words, when I load a Customer a Person is loaded and when I load a Salesman a Person is loaded too!
If the salesman and the customer recefece the same person, wouldn't it fail?
If SalesMan and Customer are loaded trought the same session object, they would reference the same person object. So, given that Person(id=1) has roles SalesMan(id=1) and Customer(id=1)
SalesMan s = session.GetObject<SalesMan>(1);
Customer c = session.GetObject<Customer>(1);
Person p = session.GetObject<Person>(1);
all of the follwing should be satisfied
object.ReferenceEquals(s.Person, p) == true
object.ReferenceEquals(c.Person, p) == true
object.ReferenceEquals(s.Person, c.Person) == true
Well, Lazy loading might create some mess... But I did not write it as c.Person == s.Person, as the Person might overload the Equals operator. And the "lazy loading mess" should not make difference from code standpoint.
Gert