Hibernate version:
0.8.6
Mapping documents:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="Horizons.BPM.ProcessModel.ProcessDefinition, Horizons.BPM"
table="ProcessDefinition">
<id name="ID" column="ID" access="nosetter.lowercase-underscore" unsaved-value="0">
<generator class="native" />
</id>
<property name="ModelID" column="ModelID" type="string" />
<property name="Name" column= "Name" type="string"/>
<property name="Version" column= "Version"/>
<property name="Description" column= "Description" type="string"/>
<property name="Duration" column= "Duration"/>
<property name="Deviation" column= "Deviation"/>
<property name="MaxScale" column= "MaxScale"/>
<property name="MinScale" column= "MinScale"/>
<property name="DurationUnit" column="DurationUnit" type="Horizons.BPM.DurationUnit, Horizons.BPM"/>
<property name="Author" column= "Author" type="string"/>
<property name="CreationDate" column="creationDate" type="DateTime"/>
<property name="State" column="State" type="Horizons.BPM.ProcessDefinitionState, Horizons.BPM"/>
<many-to-one name="ParentPackage" column="ParentPackage" not-null="true"/>
<many-to-one name="FirstActivity" access="property"
class="Horizons.BPM.ProcessModel.ActivityType.ActivityDefinition, Horizons.BPM"
column="FirstActivity"
cascade="save-update"/>
<set name="Activities" cascade="all" lazy="false" access="property" inverse="true">
<key column="ParentProcessID"/>
<one-to-many class="Horizons.BPM.ProcessModel.ActivityType.ActivityDefinition, Horizons.BPM"/>
</set>
Name and version of the database you are using:
MSSQL server 2005
My question is :
ProcessDefinition contains a set of ActivityDefinitions. One of these activities is a refered to as FirstActivity.
The problem is that when the ProcessDefinition first saves, every thing is ok. But when it updates, it gives the following error:
-----------------------------------------------------------------
UnitTests.ProcessModel.ActivityType.SubflowActivityTest.TestTransitionLogic : System.Exception : Exception in ActivateProcess
----> Horizons.BPM.DataAccess.DataAccessException : Can't save/update object.
----> NHibernate.ADOException : Could not save object
----> NHibernate.HibernateException : another object with the same id was already associated with the session: [ActivityDefinition#112]
...
...
--at DataAccessException
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
at NHibernate.Impl.SessionImpl.Save(Object obj)
at Horizons.BPM.ProcessModel.DataAccess.ProcessDefinitionDA.Save(ProcessDefinition BusinessObject) in D:\vss\PA\Version 2.0 Maintenance\Code\Horizons.BPM\Horizons.BPM\ProcessModel\DataAccess\ProcessDefinitionDA.cs:line 179
--ADOException
at NHibernate.Impl.SessionImpl.CheckUniqueness(Key key, Object obj)
at NHibernate.Impl.SessionImpl.DoUpdateMutable(Object obj, Object id, IClassPersister persister)
at NHibernate.Impl.SessionImpl.DoUpdate(Object obj, Object id, IClassPersister persister)
at NHibernate.Impl.SessionImpl.SaveOrUpdate(Object obj)
at NHibernate.Engine.Cascades.CascadingAction.ActionSaveUpdateClass.Cascade(ISessionImplementor session, Object child, Object anything)
at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, Object child, IType type, CascadingAction action, CascadeStyle style, CascadePoint cascadeTo, Object anything)
at NHibernate.Engine.Cascades.Cascade(ISessionImplementor session, IClassPersister persister, Object parent, CascadingAction action, CascadePoint cascadeTo, Object anything)
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IClassPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
----------------------------------------------------------------
If I set the cascade=none, then the reference to the FirstActivity is not saved at all.
What I need is a feature like cascade="create", which is available in the Java Hibernate long time ago.
Is there any workaround for this? Please help !
|