I'm receive the following exception if I map collection by property-ref and it need to be created for more than one object:
NHibernate.LazyInitializationException : Initializing[NHibernate.Test.NHSpecificTest.NH3557.Person#5]-failed to lazily initialize a collection of role: NHibernate.Test.NHSpecificTest.NH3557.Person.Addresses, no session or session was closed
The property-ref attribute should only be used for mapping legacy data where a foreign key refers to a unique key of the associated table other than the primary key.
(emphasis is mine)
If you are going to use RelatedPersonId as a property-ref, there should be a unique constraint on that property, which would prevent you from inserting two people who both have RelatedPersonId == 5. I'm guessing this isn't what you actually want to do, though. Just a shot in the dark, I think you probably want a many-to-one on Person named RelatedPerson, and also a one-to-many on Person named Addresses that simply points to Person.Id, not using property-ref. Then you would get the related person addresses via person1.RelatedPerson.Addresses.
I'm receive the following exception if I map collection by property-ref and it need to be created for more than one object:
NHibernate.LazyInitializationException : Initializing[NHibernate.Test.NHSpecificTest.NH3557.Person#5]-failed to lazily initialize a collection of role: NHibernate.Test.NHSpecificTest.NH3557.Person.Addresses, no session or session was closed