-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Session.delete many-to-one w/ version updates before delete
PostPosted: Mon Oct 08, 2007 9:31 am 
Newbie

Joined: Mon Feb 19, 2007 5:18 pm
Posts: 3
Location: Columbus, Ohio
Nhibernate version: 1.2.0.4000

I have two classes a Car and a Wheel. A Car has a bag of wheels:
_____________________________________________________
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="nhibernateProj" namespace="nhibernateProj" >
<class name="Car" table="Cars"
lazy="false" dynamic-update="true" optimistic-lock="version" select-before-update="true" >

<id column="UniqueID" name="mUniqueID" type="int" access="field">
<generator class="native"/>
</id>

<timestamp column="timestamp" name="mTimestamp" access="field"/>

<bag name="mWheels" cascade="all" lazy="false" inverse="true" access="field">
<key column="CarUniqueID"/>
<one-to-many class="nhibernateProj.Wheel" />
</bag>

</class>
</hibernate-mapping>
________________________________________________________

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="nhibernateProj" namespace="nhibernateProj" >
<class name="Wheel" table="Wheels"
lazy="false" dynamic-update="true" optimistic-lock="version" select-before-update="true" >

<id column="UniqueID" name="mUniqueID" type="int" access="field">
<generator class="native"/>
</id>

<timestamp column="timestamp" name="mTimestamp" access="field"/>

<many-to-one column="CarUniqueID" name="mCarIBelongTo" cascade="none" access="field"/>

</class>
</hibernate-mapping>

_________________________________________________________

Problem: Call Session.delete on a Car that has wheels. First the Car's version is updated, then deletes of wheels. Then the car is deleted. Why is an update to the car's timestamp necessary before delete?

If you remove the bag or the versoning from the equation, no update is called.

I have sample project ready if necessary.

[/b]


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.