-->
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: Cascadierendes Löschen bei joined-subclass
PostPosted: Tue Jun 07, 2005 9:20 am 
Newbie

Joined: Sun Jun 05, 2005 2:28 pm
Posts: 3
Hallo
ich habe ein problem mit dem cascadierenden Löschen. Bei one-to-many beziehung funktioniert es bei mir ohne probleme. Jetzt habe ich allerdings eine ont-to-many, die auf eine Klasse bezieht, die widerum zwei subtypen hat. Hier funktioniert das cascadierende Löschen leider nicht und ich bekomme die untene stehende Fehlermeldung. Ich habe auch schon versuch die Bezihung direkt mit den Sub-Classen zu machen, was aber haesslich ist und auch nicht funktioniert.
Außerdem habe ich alle Einstelllungen von Cascade, also all, delete, all-delete-orphan usw. probiert.
Die beiden Klassen folgen.
Würde mich sehr freuen, wenn mir jemand helfen kann.


Parent

<class name="Trainingstagebuch" table="trainingstagebuch">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
</id>

<set name="Tagebucheintrag" lazy ="true" inverse="true" cascade="all-delete-orphan">
<key>
<column name ="id"/>
</key>
<one-to-many class="Tagebucheintrag"/>
</set>




</class>

Child

<class name="Tagebucheintrag" table="Tagebucheintrag">
<id name="id" column="id" type="java.lang.Integer">
<generator class="native"/>
</id>

<property name="datum" column="datum" type="java.util.Date"/>

<many-to-one name="Trainingstagebuch" class="Trainingstagebuch" >
<column name="TrainingstagebuchID"/>
</many-to-one>


<joined-subclass name="Tagesdaten" table="tagesdaten">
<key column="id"/>
<property name="befinden" column="befinden" type="java.lang.String" />
<property name="ruhepuls" column="ruhepuls" type="int" />
</joined-subclass>

<joined-subclass name="Trainingseinheit" table="trainingseinheit">
<key column="id"/>
<property name="zielvorgabe" column="zielvorgabe" type="java.lang.String" />
</joined-subclass>

</class>




Hibernate version: 2.1

Full stack trace of any exception that occurs:

net.sf.hibernate.exception.ConstraintViolationException: could not insert: [de.tum.in.msa.model.Hbm.Tagesdaten]
at net.sf.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:73)
at net.sf.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:30)
at net.sf.hibernate.persister.AbstractEntityPersister.convert(AbstractEntityPersister.java:1332)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:554)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:419)
at net.sf.hibernate.impl.ScheduledIdentityInsertion.execute(ScheduledIdentityInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:941)
at net.sf.hibernate.impl.SessionImpl.doSave(SessionImpl.java:866)
at net.sf.hibernate.impl.SessionImpl.saveWithGeneratedIdentifier(SessionImpl.java:784)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:747)
at de.tum.in.msa.model.Hbm.base._BaseRootDAO.save(_BaseRootDAO.java:624)
at de.tum.in.msa.model.Hbm.base._BaseRootDAO.save(_BaseRootDAO.java:605)
at de.tum.in.msa.model.Hbm.base.BaseTagesdatenDAO.save(BaseTagesdatenDAO.java:60)
at de.tum.in.msa.tests.model.UserTest.testAddTagesdaten(UserTest.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)
Caused by: java.sql.SQLException: Cannot add or update a child row: a foreign key constraint fails
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
at com.mysql.jdbc.ServerPreparedStatement.serverExecute(ServerPreparedStatement.java:1366)
at com.mysql.jdbc.ServerPreparedStatement.executeInternal(ServerPreparedStatement.java:952)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1974)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1897)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1758)
at net.sf.hibernate.persister.NormalizedEntityPersister.insert(NormalizedEntityPersister.java:513)
... 25 more



Name and version of the database you are using:MySQL 4.1


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.