I have the following NHibernate mapping:--
<class name="Person" proxy="Person" table="Person_">
<id name="OID" column="OID_" type="Guid">
<generator class="guid.comb"/>
</id>
<version name="Version" column="Version_"/>
<set name="Properties" lazy="true" inverse="true" cascade="all-delete-orphan">
<key column="PersonOID_"/>
<one-to-many class="Property"/>
</set>
</class>
And the following C# code:
public class Property
{
public Person Owner;
}
public class Person
{
private ISet _properties;
public void AddProperty(Property property)
{
property.Owner = this;
_properties.Add(property);
}
public void RemoveProperty(Property property)
{
property.Owner = null;
_properties.Remove(property);
}
}
...
public void TransferProperty(Property p, Person fromPerson, Person toPerson)
{
//fromPerson.RemoveProperty(p);
toPerson.AddProperty(p);
}
A call to TransferProperty results in the entity version for toPerson getting incremented, but no change to the entity version for fromPerson.
This is causing me a problem when multiple users call TransferProperty at the same time -- because fromPerson version doesn't change, there is no PersistenceException thrown when two users try to transfer property from the same person at the same time.
Any thoughts on the best way to modify this code so that calling TransferProperty will increment the entity versions for both toPerson and fromPerson???
Thanks in advance!
Peter
P.S. I commented out the RemoveProperty call in TransferProperty, because it was resulting in "ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations)".
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "nhusers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhusers/-Q8Q7_8jyI4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhusers+u...@googlegroups.com.
Unfortunately no. Just OID and Version.
On 25 September 2015 at 11:37, Gunnar Liljas wrote:
Do you have another property on Person that can be changed explicitly instead, perhaps a ModifiedOn timestamp, thereby triggering version increment?
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+unsubscribe@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "nhusers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhusers/-Q8Q7_8jyI4/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhusers+unsubscribe@googlegroups.com.