-->
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.  [ 1 post ] 
Author Message
 Post subject: Arrays with elements part of joined-subclass mapping
PostPosted: Wed Aug 18, 2004 9:48 pm 
Newbie

Joined: Mon Aug 16, 2004 8:36 am
Posts: 7
Location: Canada
Hi All,

I have a mapping of a class with an an array element. The SQL inserts all seem correct, but I notice Hibernate subsequently does some SQL updates to the values stored in the table holding the array values for the purpose of setting the index values. The updates for the index columns look correct, but the update statement seems to also be trying to update the id field as well and this is not fine, cause its cauing duplicate id values to be set. Strange, why is hibernate subsequently trying to update the id field in addition to the index field? Any ideas?? Thanks in advance.


Hibernate version:
2.1.6
Mapping documents:
<hibernate-mapping>
<class name="acme.membership.domain.JMember">
<id name="id" type="int" unsaved-value="0">
<generator class="increment"></generator>
</id>
<property name="lastName" />
<property name="firstName" />
<property name="birthDate" type="calendar" />
<joined-subclass name="acme.membership.domain.PrimaryMember"
table="primarymember">
<key column="id" />
<array name="dependents" table="dependent" cascade="save-update">
<key column="id"/>
<index column="i" />
<one-to-many class="acme.membership.domain.Dependent"/>
</array>
<many-to-one name="address" cascade="save-update" />
<many-to-one name="contactInfo" cascade="save-update" />
</joined-subclass>
<joined-subclass name="acme.membership.domain.Dependent"
table="dependent">
<key column="id"/>
<property name="type" />
</joined-subclass>

</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:
DB2 8.1
Debug level Hibernate log excerpt:
Here's the offending portion of the log:

Hibernate: update dependent set id=?, i=? where id=?
21:21:13,785 DEBUG IntegerType:46 - binding '1' to parameter: 1
21:21:13,785 DEBUG IntegerType:46 - binding '2' to parameter: 3
21:21:13,785 DEBUG IntegerType:46 - binding '0' to parameter: 2
Hibernate: update dependent set id=?, i=? where id=?
21:21:13,785 DEBUG IntegerType:46 - binding '1' to parameter: 1
21:21:13,785 DEBUG IntegerType:46 - binding '3' to parameter: 3
21:21:13,785 DEBUG IntegerType:46 - binding '1' to parameter: 2
21:21:13,795 WARN JDBCExceptionReporter:38 - SQL Error: -803, SQLState: 23505
21:21:13,795 ERROR JDBCExceptionReporter:46 - [IBM][CLI Driver][DB2/NT] SQL0803N One or more values in the INSERT statement, UPDATE statement, or foreign key update caused by a DELETE statement are not valid because the primary key, unique constraint or unique index identified by "1" constrains table "AMANJI.DEPENDENT" from having duplicate rows for those columns. SQLSTATE=23505


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.