-->
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: relation problem using bag
PostPosted: Thu Oct 14, 2004 7:45 am 
Newbie

Joined: Thu Oct 14, 2004 7:38 am
Posts: 5
Hibernate version:
2.1.6
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 between sessionFactory.openSession() and session.close():
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);
}

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.


any idea ?


Top
 Profile  
 
 Post subject: relation problem using bag
PostPosted: Thu Oct 14, 2004 8:57 am 
Newbie

Joined: Thu Oct 14, 2004 7:38 am
Posts: 5
one more:

when changing mapping to (with cascade=all):
<bag name="RwpXVersRelevants" lazy="true" cascade="all">

as you can see in the debug-trace, there is first an "update" and later a "delete" (which will never work work because of the previous update).

...
DEBUG net.sf.hibernate.collection.AbstractCollectionPersister,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.AbstractCollectionPersister,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#catiaVariable = '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=?
...


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.