-->
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: Is this a bug ?
PostPosted: Wed May 25, 2005 5:20 pm 
Newbie

Joined: Wed May 11, 2005 5:48 pm
Posts: 1
I am mapping a legacy database model with Hibernate. Now I got an
ConstraintViolationException. I think it is a bug. Here is simple test case which show my problem:

Hibernate version:
3.0.4/3.05

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

<hibernate-mapping package="test">

<class name="Parent" lazy="true" table="T_PARENT">
<composite-id name="key">
<key-property name="id1"/>
<key-property name="id2"/>
</composite-id>
<property name="name"/>
<set name="childs" lazy="true" order-by="id3" cascade="all">
<key>
<column name="id1"/>
<column name="id2"/>
</key>
<one-to-many class="Child"/>
</set>
</class>

<class name="Child" lazy="true" table="T_CHILD">
<composite-id name="key">
<key-property name="id1" />
<key-property name="id2" />
<key-property name="id3" />
</composite-id>
<property name="name" />
</class>

</hibernate-mapping>

Code between sessionFactory.openSession() and session.close():
Parent parent = new Parent();
parent.setKey(new Key(1, 1));
parent.setName("Parent");
Child child = new Child();
child.setKey(new Key(1, 1, 0));
child.setName("Child");
parent.getChilds().add(child);

session.save(parent);
session.flush();

parent.getChilds().remove(child);
session.flush();

Full stack trace of any exception that occurs:
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:63)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:179)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:139)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:726)
at test.BugTest.testXX(BugTest.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:474)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:342)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:194)
Caused by: Batch-Anweisung Nummer 0 (update T_CHILD set id1=null, id2=null where id1=) wurde abgebrochen.
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:107)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:172)
... 21 more

Name and version of the database you are using:
Postgresql 7.4, Oracle 9

The generated SQL (show_sql=true):
Hibernate: select child_.id1, child_.id2, child_.id3, child_.name as name1_ from T_CHILD child_ where child_.id1=? and child_.id2=? and child_.id3=?
Hibernate: insert into T_PARENT (name, id1, id2) values (?, ?, ?)
Hibernate: insert into T_CHILD (name, id1, id2, id3) values (?, ?, ?, ?)
Hibernate: update T_CHILD set id1=?, id2=? where id1=? and id2=? and id3=?
Hibernate: update T_CHILD set id1=null, id2=null where id1=? and id2=?


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.