-->
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: DB2 7.2 - problem updating all-delete-orphans
PostPosted: Thu Nov 04, 2004 12:12 pm 
Beginner
Beginner

Joined: Mon Aug 23, 2004 12:44 am
Posts: 25
Hello,

I'm having a problem on DB2when deleting an object. It seems to be related to the fact the object in question has "all-delete-orphan" collections defined.

The problem does not occur on MySql.

The problem seems to arise when flushing the session\synchronizing the session with the db.

More in particular it seems related to Hibernate trying to execute an update statement.

Following is a small extract of the log produced when running on DB2 (the detailed stack trace is attached further below) and on MySql:

DB2 log extract (see below for full extract):
14:13:35,970 DEBUG SessionImpl:2359 - executing flush
14:13:35,970 DEBUG BasicCollectionPersister:477 - Deleting collection: [com.eds.finframe.esese.persistence.ResolverDefinition.resolverOperandDefinitions#23]
14:13:35,970 DEBUG BatcherImpl:200 - about to open: 0 open PreparedStatements, 0 open ResultSets
14:13:35,970 DEBUG SQL:226 - update LBTBRD01_rod set parentRDUID=null, name=null where parentRDUID=?
14:13:35,970 DEBUG SQL:226 - update LBTBRD01_rod set parentRDUID=null, name=null where parentRDUID=?
14:13:35,970 DEBUG BatcherImpl:249 - preparing statement
14:13:35,970 DEBUG LongType:46 - binding '23' to parameter: 1
14:13:35,970 DEBUG LongType:46 - binding '23' to parameter: 1
14:13:35,980 DEBUG BatcherImpl:207 - done closing: 0 open PreparedStatements, 0 open ResultSets
14:13:35,980 DEBUG BatcherImpl:269 - closing statement
14:13:35,980 DEBUG JDBCExceptionReporter:36 - SQL Exception
14:13:35,980 ERROR JDBCExceptionReporter:38 - could not delete collection: [com.eds.finframe.esese.persistence.ResolverDefinition.resolverOperandDefinitions#23]
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0407N Assignment of a NULL value to a NOT NULL column "NAME" is not allowed. SQLSTATE=23502

When running on MySQL the log shows (see below for full extract):
...
14:16:37,855 DEBUG SessionImpl:2359 - executing flush
14:16:37,855 DEBUG BasicCollectionPersister:477 - Deleting collection: [com.eds.finframe.esese.persistence.ResolverDefinition.resolverOperandDefinitions#6]
14:16:37,855 DEBUG BatcherImpl:200 - about to open: 0 open PreparedStatements, 0 open ResultSets
14:16:37,855 DEBUG SQL:226 - update LBTBRD01_rod set parentRDUID=null, name=null where parentRDUID=?
14:16:37,855 DEBUG SQL:226 - update LBTBRD01_rod set parentRDUID=null, name=null where parentRDUID=?
14:16:37,855 DEBUG BatcherImpl:249 - preparing statement
14:16:37,855 DEBUG LongType:46 - binding '6' to parameter: 1
14:16:37,855 DEBUG LongType:46 - binding '6' to parameter: 1
14:16:37,855 DEBUG BatcherImpl:28 - Adding to batch
... MySQl continues without exception.


Notice the difference. Just after binding the parameters, DB2 log shows "BatcherImpl:207 - done closing: 0 open ", whereas the MySql log shows "BatcherImpl:28 - Adding to batch".

Do you have any clue why this problem is occuring ?

Kind regards,

Edwin

Hibernate version:
2.1.6

Mapping documents:
RESOLVER DECLARATION:<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>

<!-- Hibernate mapping for the ResolverDeclaration -->

<class name="com.eds.finframe.esese.persistence.ResolverDeclaration"
table="LBTBRD01_rdcl" optimistic-lock="version"
dynamic-update="true">

<meta attribute="class-description">
Concept, realization and future extensions on this Basic Intellectual Property are under Copyright


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 06, 2004 8:36 am 
Newbie

Joined: Mon Dec 06, 2004 4:52 am
Posts: 5
Hi,

if I understand your problem correctly we had a similar problem.
We had a collection and when deleting the object that holds the collection the collection itself should be deleted, too.
At commit Hibernate first updates the reference with null and tries to insert a null value in a column that shouldn't be null.

Mysql does not seem to care about null columns.

For us the following worked: Add inverse="true" in the mapping.
<set name="..." cascade="all-delete-orphan"
inverse="true"

Have a look at "The Bible of Hibernate" chapter 4.3.3 page 143.


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.