I am using an extra database, and want to replicate data from one database to another using nhibernate.
Each database has its own sessionFactory, and connection.
First I save the data in the first database using the standard Save method, and replicated data with the Replicate method, with the option Overwrite set.
This approach works for all my objects, except those who use the joined-subclass tag in the hbm.xml file. I can perfectly save these objects using the Save method, but when invoking the Replicate method an error happens. The error claims that the specific version of my joined-subclass does not exist in the database. I have visually inspected this, and the data is available.
Could it be an issue between joined-subclasses and the replicate method?
The error is as i can see identical to this old jira issue on the Java version
http://opensource.atlassian.com/projects/hibernate/browse/HB-609?page=history
Except i get an ADO exception using .net.
Hibernate version:
1.0.2.0
Mapping files
<class name="XXX.Class1, ComponentName" table="Class1">
<id name="DataId" column= "id" type="Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid" />
</id>
</class>
<joined-subclass name="XXX.menu, ComponentName" table="menu"
dynamic-update="false"
dynamic-insert="false"
extends="XXX.Class1, ComponentName">
<key column="parentpageid" />
<list name="MenusList" cascade="all">
<key column="menusid" />
<index column="posn" />
<one-to-many class="XXX.MenuItem, ComponentName" />
</list>
</joined-subclass>
<class name="XXX.MenuItem, ComponentName" table="menuitem">
<id name="DataId" column= "id" type="Guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid" />
</id>
<property name="Name" column="name" type="String"/>
<list name="ItemModesList" cascade="all" table="mdfmenumode">
<key column="menuid" />
<index column="posn" />
<composite-element class="XXX.ItemModesElement, ComponentName">
<property name="Menu" column="menu" type="String"/>
<property name="Mode" column="mode" type="Int32"/>
</composite-element>
</list>
</class>
Code between sessionFactory.openSession() and session.close():
session = factory.OpenSession();
transaction = session.BeginTransaction();
session.Replicate(newObject.Version, ReplicationMode.Overwrite);
session.Replicate(newObject, ReplicationMode.Overwrite);
transaction.Commit();
Full stack trace of any exception that occurs:
at NHibernate.Persister.AbstractEntityPersister.GetCurrentVersion(Object id, ISessionImplementor session)
at NHibernate.Impl.SessionImpl.Replicate(Object obj, ReplicationMode replicationMode)
at NHibernate.Engine.Cascades.CascadingAction.ActionReplicateClass.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.CascadeCollection(CascadingAction action, CascadeStyle style, PersistentCollectionType collectionType, IType elemType, Object child, CascadePoint cascadeVia, ISessionImplementor session, 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 theObj, Key key, IClassPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.Replicate(Object obj, ReplicationMode replicationMode)
Name and version of the database you are using:
SQLExpress
Thanks
SWJust