-->
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.  [ 4 posts ] 
Author Message
 Post subject: Unnecessary updates when adding a new Child to a Parent
PostPosted: Thu Sep 01, 2005 8:18 am 
Newbie

Joined: Thu Sep 01, 2005 7:56 am
Posts: 2
My problem is the following: I have a parent/child relationship between a List and an Entry: a List may contain multiple entries. Each time I had a new Entry to the list, Hibernate issues an update statement for each and every other entry in the list, whic is a performance kill (some lists may have thousands of entries).

Any idea what's going wrong here?

My configuration is the following:

Hibernate version:3.0.5

Mapping documents:
The relation is bidirectional:

Parent:
<hibernate-mapping>
<class
...
name="com.viveo.rtcc.plugins.gis.server.domainmodel.List"
<set name="entries" inverse="true" cascade="all-delete-orphan" lazy="true">
<key column="FK_GIS_LIST"/>
<one-to-many class="com.viveo.rtcc.plugins.gis.server.domainmodel.Entry"/>
</set>
...
</hibernate-mapping>

Child:
<hibernate-mapping>
<class
...
name="com.viveo.rtcc.plugins.gis.server.domainmodel.Entry"
<many-to-one
name="list"
column="FK_GIS_LIST"
class="com.viveo.rtcc.plugins.gis.server.domainmodel.List"
not-null="true" />
...
</hibernate-mapping>



Code between sessionFactory.openSession() and session.close():

Entry entry = createAndInitializeNewEntry();
List list = (List) session.get(List.class, aListId);
entry.setList(list);
list.getEntries().add(entry); // getEntries returns the Set of entries


Full stack trace of any exception that occurs:

Name and version of the database you are using: IBM DB2

The generated SQL (show_sql=true):
Hibernate: insert into TXXXGIS_ENTRY (TYPE, NAME, SURNAME, HONORIFIC, CHIPS_UID, SWIFT_IDENTIFIER, IS_DANGEROUS, SDN_CATEGORY, PERMUTATION_GEN, ENTRY_FACPLUS_ID, NAT_ID, ORIGINAL_ID, AFF_CODE, IS_DELETED, FED, STATUS, IMPORT_FLAG, FK_GIS_LIST, FK_ENRICHMENT, PK_GIS_ENTRY) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: update TXXXGIS_LIST set LIST_TYPE=?, LIST_NAME=?, LIST_DESCRIPTION=?, PROJECT_ID=?, FK_MANDATOR_ID=? where PK_GIS_LIST=?

Hibernate: update TXXXGIS_ENTRY set TYPE=?, NAME=?, SURNAME=?, HONORIFIC=?, CHIPS_UID=?, SWIFT_IDENTIFIER=?, IS_DANGEROUS=?, SDN_CATEGORY=?, PERMUTATION_GEN=?, ENTRY_FACPLUS_ID=?, NAT_ID=?, ORIGINAL_ID=?, AFF_CODE=?, IS_DELETED=?, FED=?, STATUS=?, IMPORT_FLAG=?, FK_GIS_LIST=?, FK_ENRICHMENT=? where PK_GIS_ENTRY=?
Hibernate: update TXXXGIS_ENTRY set TYPE=?, NAME=?, SURNAME=?, HONORIFIC=?, CHIPS_UID=?, SWIFT_IDENTIFIER=?, IS_DANGEROUS=?, SDN_CATEGORY=?, PERMUTATION_GEN=?, ENTRY_FACPLUS_ID=?, NAT_ID=?, ORIGINAL_ID=?, AFF_CODE=?, IS_DELETED=?, FED=?, STATUS=?, IMPORT_FLAG=?, FK_GIS_LIST=?, FK_ENRICHMENT=? where PK_GIS_ENTRY=?

...

Hibernate: update TXXXGIS_ENTRY set TYPE=?, NAME=?, SURNAME=?, HONORIFIC=?, CHIPS_UID=?, SWIFT_IDENTIFIER=?, IS_DANGEROUS=?, SDN_CATEGORY=?, PERMUTATION_GEN=?, ENTRY_FACPLUS_ID=?, NAT_ID=?, ORIGINAL_ID=?, AFF_CODE=?, IS_DELETED=?, FED=?, STATUS=?, IMPORT_FLAG=?, FK_GIS_LIST=?, FK_ENRICHMENT=? where PK_GIS_ENTRY=?

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 8:37 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
What's your Entry class mapping?

I hope you don't have this:

dynamic-update="true|false"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 8:44 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Ups.

Previous post has nothing to do with your problem.

>> Mapping an association (either a single valued association, or a collection) with cascade="all" marks the association as a parent/child style relationship where save/update/delete of the parent results in save/update/delete of the child or children.

It's the cascading type.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 01, 2005 11:37 am 
Newbie

Joined: Thu Sep 01, 2005 7:56 am
Posts: 2
I think I found what the problem is. Someone changed the Entry class and added a trim() in some of the getters. So the getter return actually a different string than what the setter got. Hence the updates ...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.