java amateur
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
java amateur
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
java amateur
java amateur
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
java amateur
Originally posted by miguel lisboa:
one curious thing is that hibernate wont let me delete Contrato unless i first remove it from both collections
Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
java amateur
Originally posted by miguel lisboa:
with cascade="none" all goes fine but with "save-update" i get an ugly ObjectDeleteException:
deleted object would be re-saved by cascade (remove deleted object from associations)
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
If I understand you correctly, you are removing the object from one of the collections. That would mean (with cascade activated) that the object also should be deleted from the database, *but* it is still needed by the other collection, so it also needs to *remain* in the database. Kind of a conflict, isn't it?
java amateur
Originally posted by miguel lisboa:
what i was refering to was that i was trying to delete a Contrato (from db)- to which hibernate opposes - without first removing it from collections
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
If you delete the "Contrato" from the db, and save one of the collections, what would hibernate be supposed to do?
java amateur
net.sf.hibernate.ObjectDeletedException: deleted object would be re-saved by cascade (remove deleted object from associations): 2, of class: logica.ContratoConvencao
at net.sf.hibernate.impl.SessionImpl.forceFlush(SessionImpl.java:761)
at net.sf.hibernate.impl.SessionImpl.save(SessionImpl.java:739)
at net.sf.hibernate.impl.SessionImpl.saveOrUpdate(SessionImpl.java:1385)
at net.sf.hibernate.engine.Cascades$4.cascade(Cascades.java:114)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:436)
at net.sf.hibernate.engine.Cascades.cascadeCollection(Cascades.java:526)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:452)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:503)
at net.sf.hibernate.engine.Cascades.cascade(Cascades.java:482)
at net.sf.hibernate.impl.SessionImpl.preFlushEntities(SessionImpl.java:2693)
at net.sf.hibernate.impl.SessionImpl.flushEverything(SessionImpl.java:2270)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2259)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
at persistencia.ContratoConvencaoDao.elimina(ContratoConvencaoDao.java:92)
at persistencia.TesteCascades.testCascade_all_delete_orphan(TesteCascades.java:129)
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)
java amateur
this test takes 3,755 sec plus time to create db (another 3+ seconds)
java amateur
So it takes a day for light to pass through this glass? So this was yesterday's tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|