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.  [ 2 posts ] 
Author Message
 Post subject: Problem with flush session used with many to many saveUpdate
PostPosted: Sun Jun 01, 2008 3:09 pm 
Newbie

Joined: Tue May 15, 2007 4:38 am
Posts: 5
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:2.2

Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="Horizons.BPM">
<class name="Horizons.BPM.Measure.AbstractMeasure" table="Measure" dynamic-update="true" optimistic-lock="version"
proxy="Horizons.BPM.Measure.IAbstractMeasure">
<id name="ID" column="ID" access="property" unsaved-value="0">
<generator class="native" />
</id>

<discriminator column="Discriminator" type="string"/>

<timestamp column="TimeStamp" name="TimeStamp" />

<many-to-one name="MeasureDefinition" column="MeasureDefinitionID" cascade="all" class="Horizons.BPM.Measure.MeasureDefinition, Horizons.BPM" fetch="join" lazy="false"/>

<set name="Alerts" cascade="all" inverse="true" fetch="join" access="property" lazy="false" table="MeasuresAlerts" optimistic-lock="false">
<key column="MeasureID"/>
<many-to-many class="Horizons.BPM.Measure.Alert" column="AlertID"/>
</set>

<set name="AlertObservations" cascade="all" fetch="join" access="property" inverse="true" lazy="false" optimistic-lock="false" >
<key column="MeasureID"/>
<one-to-many class="Horizons.BPM.Measure.AlertObservation"/>
</set>

<set name="Observations" cascade="all" fetch="join" access="property" lazy="false" optimistic-lock="false">
<key column="MeasureID"/>
<one-to-many class="Horizons.BPM.Measure.Observation"/>
</set>

<set name="TimePeriods" cascade="save-update" access="property" inverse="false" lazy="false" table="MeasuresTimePeriods" optimistic-lock="false">
<key column="MeasureID"/>
<many-to-many class="Horizons.BPM.Measure.TimePeriod" column="TimePeriodID"/>
</set>

<subclass
name="Horizons.BPM.Measure.ProcessMeasure"
extends="Horizons.BPM.Measure.AbstractMeasure" dynamic-update="true"
discriminator-value="ProcessMeasure" proxy="Horizons.BPM.Measure.IProcessMeasure">

<many-to-one name="ParentProcess" column="ProcessID" cascade="none" class="Horizons.BPM.ProcessModel.ProcessDefinition" fetch="join" lazy="false"/>
<property name="AppliesForAllInstances" column="AppliesForAllInstances" />

<subclass
name="Horizons.BPM.Measure.InstanceMeasure"
extends="Horizons.BPM.Measure.ProcessMeasure" dynamic-update="true"
discriminator-value="InstanceMeasure" proxy="Horizons.BPM.Measure.IInstanceMeasure">
<many-to-one name="ParentRuntimeProcess" column="RuntimeProcessID" cascade="none" class="Horizons.BPM.ProcessModel.Runtime.RuntimeProcess" fetch="join" lazy="false" />

</subclass>
</subclass>

<subclass
name="Horizons.BPM.Measure.ResourceMeasure"
extends="Horizons.BPM.Measure.AbstractMeasure" dynamic-update="true"
discriminator-value="ResourceMeasure" proxy="Horizons.BPM.Measure.IResourceMeasure">
<many-to-one name="ParentAccountableParty" column="ResourceID" cascade="none" class="Horizons.BPM.Organization.AccountableParty" fetch="join" lazy="false" />

</subclass>


</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
try
{
CheckSession();
//session.Refresh(measure);
session.SaveOrUpdate(measure);
session.Flush();
result = OperationResult.SUCCESS;
}
finally
{
if (session != null)
session.Clear();
}


Full stack trace of any exception that occurs:
Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for Horizons.BPM.Measure.ProcessMeasure instance with identifier: 5
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: NHibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for Horizons.BPM.Measure.ProcessMeasure instance with identifier: 5

Source Error:


Line 131: {
Line 132: result = OperationResult.FAIL;
Line 133: throw ex;
Line 134: }
Line 135: finally


Source File: E:\vss\PA\Version 2.6\Code 2.6\Horizons.BPM\Horizons.BPM\Measure\DataAccess\MeasureDataAccess.cs Line: 133

Stack Trace:


[StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for Horizons.BPM.Measure.ProcessMeasure instance with identifier: 5]
Horizons.BPM.Measure.MeasureDataAccess.SaveMeasures(IList myMeasures) in E:\vss\PA\Version 2.6\Code 2.6\Horizons.BPM\Horizons.BPM\Measure\DataAccess\MeasureDataAccess.cs:133
Horizons.BPM.Measure.MeasureManager.SaveMeasures(IList myMeasures) in E:\vss\PA\Version 2.6\Code 2.6\Horizons.BPM\Horizons.BPM\Measure\MeasureManager.cs:59
Horizons.BPM.Measure.MeasureService.SaveMeasures(IList myMeasures) in E:\vss\PA\Version 2.6\Code 2.6\Horizons.BPM\Horizons.BPM\Measure\MeasureService.cs:119

[Exception: Exception in Save Measure]
Horizons.BPM.Measure.MeasureService.SaveMeasures(IList myMeasures) in E:\vss\PA\Version 2.6\Code 2.6\Horizons.BPM\Horizons.BPM\Measure\MeasureService.cs:143
frmMeasureObservations.Save() in e:\vss\PA\Version 2.6\Code 2.6\Horizons.BPM\PA Client_7_5\frmMeasureObservations.aspx.cs:154
frmMeasureObservations.imbSave_Click(Object sender, ImageClickEventArgs e) in e:\vss\PA\Version 2.6\Code 2.6\Horizons.BPM\PA Client_7_5\frmMeasureObservations.aspx.cs:132
System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +86
System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +115
System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


Name and version of the database you are using:SQL Server 2005

the problem occurs where save a measure that has a new alert added (which related to the measure by many to many relationship) then update the same measure


Top
 Profile  
 
 Post subject: Save Issue
PostPosted: Tue Jun 03, 2008 9:55 am 
Newbie

Joined: Sun May 18, 2008 1:21 pm
Posts: 13
Hi,

You have to check you database relation ships. May be some invalid cascading is enabled e.g on child table you have put cascade.

I was also facing this issue but the only issue is with Database relationships.

Hope this help's u.

Zafar


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

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.