Announcement Announcement Module
Collapse
No announcement yet.
Hibernate-parent/child: unwanted update performed on child Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate-parent/child: unwanted update performed on child

    Hello,

    I.m using Hibernate version: 2.1.6, Spring 1.1
    Hibernate Mapping documents:
    <class name="VersRel" >
    <id name="id" type="integer" column="ID" >
    <generator class="assigned"></generator>
    </id>

    <bag name="RwpXVersRelevants" lazy="true" >
    <key column="IDRELV" />
    <one-to-many class="RwpXVersRelevant"/>
    </bag>
    </class>

    <class name="RwpXVersRelevant" >
    <composite-id>
    <key-many-to-one name="catiaVariable" class="CatiaVariable" column="IDVAR" />
    <key-many-to-one name="versRel" class="VersRel" column="IDRELV"/>
    </composite-id>
    </class>

    Code :
    public void deleteVersRelDeep(int versRelId)
    {
    VersRel versRel = loadVersRel(versRelId);
    // List list = versRel.getRwpXVersRelevants(); //createCriteriaRwpXVersRelevant().add(Expression.eq (RwpXVersRelevant.VERSREL, versRel)).list();
    // for (Iterator iter = list.iterator(); iter.hasNext()
    // {
    // RwpXVersRelevant rwpXVersRelevant = (RwpXVersRelevant) iter.next();
    // _deleteRwpXVersRelevant(rwpXVersRelevant);
    // }
    _deleteVersRel(versRel); // calls: getSession().delete(versRel)
    }

    after call of "deleteVersRelDeep" in all rows of "RwpXVersRelevants" the field "IDRELV" is set to null.
    I got the same result, when commenting out the code above.

    The logging:
    ...
    DEBUG net.sf.hibernate.collection.AbstractCollectionPers ister,477 - Deleting collection: [de.bmw.catia.model.data.VersRel.RwpXVersRelevants# 8]
    DEBUG net.sf.hibernate.impl.BatcherImpl,200 - about to open: 0 open PreparedStatements, 0 open ResultSets
    DEBUG net.sf.hibernate.impl.BatcherImpl,226 - update RWP_X_VERS_RELEVANT set IDRELV=null where IDRELV=?
    DEBUG net.sf.hibernate.impl.BatcherImpl,249 - preparing statement
    DEBUG net.sf.hibernate.type.NullableType,46 - binding '8' to parameter: 1
    DEBUG net.sf.hibernate.impl.BatchingBatcher,28 - Adding to batch
    DEBUG net.sf.hibernate.collection.AbstractCollectionPers ister,493 - done deleting collection
    DEBUG net.sf.hibernate.impl.BatchingBatcher,50 - Executing batch size: 1
    DEBUG net.sf.hibernate.impl.BatchingBatcher,58 - success of batch update unknown: 0
    DEBUG net.sf.hibernate.impl.BatcherImpl,207 - done closing: 0 open PreparedStatements, 0 open ResultSets
    DEBUG net.sf.hibernate.impl.BatcherImpl,269 - closing statement
    DEBUG net.sf.hibernate.persister.EntityPersister,570 - Deleting entity: [de.bmw.catia.model.data.RwpXVersRelevant#catiaVari able = '1 - ChangeNameOnReplace=', versRel = 'de.bmw.catia.model.data.VersRel@1db9f45', isDeleted = 'false', isRelevant = 'false', text = 'null']
    DEBUG net.sf.hibernate.impl.BatcherImpl,200 - about to open: 0 open PreparedStatements, 0 open ResultSets
    DEBUG net.sf.hibernate.impl.BatcherImpl,226 - delete from RWP_X_VERS_RELEVANT where IDVAR=? and IDRELV=?
    ...

    As you can see there is an update performed:
    update RWP_X_VERS_RELEVANT set IDRELV=null where IDRELV=?

    any idea why ? is it a hibernate only issue ?

    Thanks for any help !

  • #2
    Re: Hibernate-parent/child: unwanted update performed on chi

    [qouote]
    any idea why ? is it a hibernate only issue ?

    Thanks for any help ![/quote]

    Add inverse="true" parameter to Your bag. Take a look at: http://www.hibernate.org/155.html

    Comment


    • #3
      thank you - it work's now !

      Comment

      Working...
      X