I have a persistent object with a many-to-one collection. Upon retrieving this object from the db I'm wanting to remove objects from the Set and add new ones as appropriate. I was reading in 14.1.4 of the hib documentation about being able to dereference the collection (Set) on the persistent object in order to allow all recs to be deleted, then create a new Set and put the new objects to be persisted in there and then go about a saveOrUpdate() on the parent persistent object. In my test I have one object in the Set - I then go about dereferencing the Set (setting it to null in the parent object), instantiating a new HashSet, and then adding two new objects to the Set, then doing a saveOrUpdate() on the parent. What happens is the two additional rows are written to the db and I see a constraint violation because it's attempting to re-add the first row. Doesn't look like the deletes are happening. How should this be achieved?
Hibernate version is: 2.1.2
Database: Oracle 8i 8.1.7
Stack trace:
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 1, SQLState: 23000
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 1, SQLState: 23000
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] ERROR net.sf.hibernate.util.JDBCExceptionReporter - [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (INDPFP.XAK1PORTFOLIO_PARTY) violated
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] ERROR net.sf.hibernate.util.JDBCExceptionReporter - [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (INDPFP.XAK1PORTFOLIO_PARTY) violated
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 1, SQLState: 23000
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] WARN net.sf.hibernate.util.JDBCExceptionReporter - SQL Error: 1, SQLState: 23000
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] ERROR net.sf.hibernate.util.JDBCExceptionReporter - [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (INDPFP.XAK1PORTFOLIO_PARTY) violated
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] ERROR net.sf.hibernate.util.JDBCExceptionReporter - [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (INDPFP.XAK1PORTFOLIO_PARTY) violated
19-May-2004 09:11:20 [org.junitee.runner.TestRunner@1399f26] ERROR net.sf.hibernate.util.JDBCExceptionReporter - Could not execute JDBC batch update
weblogic.jdbc.base.BaseBatchUpdateException: [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (INDPFP.XAK1PORTFOLIO_PARTY) violated
at weblogic.jdbc.base.BasePreparedStatement.executeOneStatementAtATime(Unknown Source)
at weblogic.jdbc.base.BaseStatement.executeBatchEmulation(Unknown Source)
at weblogic.jdbc.base.BasePreparedStatement.executeBatch(Unknown Source)
at weblogic.jdbc.wrapper.PreparedStatement_weblogic_jdbc_base_BasePreparedStatement.executeBatch(Unknown Source)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at com.pwc.us.pfp.firmportfolio.datagateway.hibernate.HibFirmPortfolioDataGateway.updateFirmPortfolio(HibFirmPortfolioDataGateway.java:153)
at com.pwc.us.pfp.firmportfolio.services.FirmPortfolioServicesBean.updateFirmPortfolio(FirmPortfolioServicesBean.java:90)
at com.pwc.us.pfp.firmportfolio.services.FirmPortfolioServices_kxm0gg_ELOImpl.updateFirmPortfolio(FirmPortfolioServices_kxm0gg_ELOImpl.java:157)
at com.pwc.us.pfp.firmportfolio.services.test.FirmPortfolioSvcsTest.testUpdateFirmPortfolio(FirmPortfolioSvcsTest.java:216)
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.junitee.runner.TestRunner$1.run(TestRunner.java:72)
|