Friends,
This is the scenario. I have a table(CA) which has 2 parents(C and A). I am trying to move data from one database(D1) to another(D2) using replicate. Inserts and updates are working fine. However it is during delete that I am facing issues and requesting your help. If CA in D2 already has 2 records (c_id=1 and a_id=1 ; c_id=2 and a_id=2). If the present object from D1 has only one record(c_id=1 and a_id=1), I wanted the other record(c_id=2 and a_id=2) to be delete from CA in D2. But that is not happening.
Please see the mapping information and code snippet below for additional info.
Hibernate version:3.0.1
Mapping from Parent(C) :
<!-- bi-directional one-to-many association to CA --> <set name="cas" lazy="false" inverse="true" cascade="all,delete-orphan" > <meta attribute="field-description"> @hibernate.set lazy="false" inverse="true" cascade="all-delete-orphan"
@hibernate.collection-key column="c_id"
@hibernate.collection-one-to-many class="com.foo.xyz.beans.Ca" </meta> <key> <column name="c_id" /> </key> <one-to-many class="com.foo.xyz.beans.Ca" /> </set>
This is the mapping from other parent(A)
<!-- bi-directional one-to-many association to CA --> <set name="cas" lazy="false" inverse="true" cascade="none" > <meta attribute="field-description"> @hibernate.set lazy="true" inverse="true" cascade="none"
@hibernate.collection-key column="a_id"
@hibernate.collection-one-to-many class="com.foo.xyz.beans.Ca" </meta> <key> <column name="a_id" /> </key> <one-to-many class="com.foo.xyz.beans.Ca" /> </set>
Code Snippet:
List lst = D1.getList();
for (Iterator l_oIterator = lst.iterator(); lst.hasNext();) {
Obj obj = (Obj) lst.next();
Hibernate.initialize(obj);
D1Session.closeSession();
D2Connection.beginTransaction();
D2Connection.getSession().replicate(
obj, ReplicationMode.OVERWRITE);
D2Connection.commitTransaction();
}
Full stack trace of any exception that occurs: NO ERRORS or EXCEPTIONS
Name and version of the database you are using: Informix 9.3.0
Any help would be greatly appreciated. Thanks in advance.
|