-->
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: error during synchronization
PostPosted: Fri May 19, 2006 4:04 am 
Newbie

Joined: Fri May 19, 2006 3:02 am
Posts: 1
Hi all,
I've got a really weird error when hibernate tries to synchronize its objects with the database.
I have a n:1 relation between two tables. Then I created two new objects and did a "session.save" on both of them. After this the new objects have received a primary-key from the database (Though they aren't stored yet). When I do a session.flush(), Hibernate tries to insert the "n-object" (clasheetratio) before the "1-object" (clasection) and hence an foreign key violation error occurs:

org.hibernate.util.JDBCExceptionReporter - ORA-01400: cannot insert NULL into ("RZBBCO"."CLASHEETRATIO"."SECTION_ID")

The strange thing is, that the hibernate objects are ok. Before flushing to the database the concerned hibernate objects look like this (:

at.rzb.cla.bl.hbm.generated.Clasection getSectionId:304 getSectionCode:BD getSectionSort:0 getClalngtxtLangId:BD getClatab:at.rzb.cla.bl.hbm.generated.Clatab@5fe7c7f6[tabId=50] getClasheetratios:[]

at.rzb.cla.bl.hbm.generated.Clasheetratio getSheetratioId:9176 getSheetratioSort:1 getSheetratioMandatory:N getSheetratioDatapoolRel:null getSheetratioRatingRatioRel:null getSheetratioFormatString:General getSheetratioFormatCode:Font05 getSheetratioMapping: getClamastersheet:at.rzb.cla.bl.hbm.generated.Clamastersheet@364887c8[mastersheetId=37] getClasection:at.rzb.cla.bl.hbm.generated.Clasection@5fdac7f6[sectionId=304] getClaratio:at.rzb.cla.bl.hbm.generated.Claratio@67fc47f1[ratioId=4316] getStdclafieldtype:at.rzb.cla.bl.hbm.generated.Stdclafieldtype@193307f6[clafieldtypeId=2] getClasheetratiomodels:null getClasheetratiobcoratios:[]

what now happens is that hibernate tries to insert Clasheetratio before it inserts the corresponcing Clasection object:

2006-05-18 18:53:59,806 DEBUG [P=945455:O=0:CT] org.hibernate.jdbc.AbstractBatcher.log(AbstractBatcher - insert into CLASHEETRATIO (SHEETRATIO_SORT, SHEETRATIO_MANDATORY, SHEETRATIO_DATAPOOL_REL, SHEETRATIO_RATING_RATIO_REL, SHEETRATIO_FORMAT_STRING, SHEETRATIO_FORMAT_CODE, SHEETRATIO_MAPPING, MASTERSHEET_ID, SECTION_ID, RATIO_ID, CLAFIELDTYPE_ID, SHEETRATIO_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2006-05-18 18:53:59,806 DEBUG [P=945455:O=0:CT] org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher - preparing statement
2006-05-18 18:53:59,806 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding '1' to parameter: 1
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding 'N' to parameter: 2
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding null to parameter: 3
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding null to parameter: 4
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding 'General' to parameter: 5
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding 'Font05' to parameter: 6
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding '' to parameter: 7
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding '37' to parameter: 8
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding null to parameter: 9
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding '4316' to parameter: 10
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding '2' to parameter: 11
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.type.NullableType.nullSafeSet(NullableType - binding '9176' to parameter: 12
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.jdbc.BatchingBatcher - Adding to batch
2006-05-18 18:53:59,822 DEBUG [P=945455:O=0:CT] org.hibernate.jdbc.BatchingBatcher - Executing batch size: 1
2006-05-18 18:54:03,369 DEBUG [P=945455:O=0:CT] org.hibernate.jdbc.AbstractBatcher.logClosePreparedStatement(AbstractBatcher - about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
2006-05-18 18:54:03,369 DEBUG [P=945455:O=0:CT] org.hibernate.jdbc.AbstractBatcher.closePreparedStatement(AbstractBatcher - closing statement
2006-05-18 18:54:03,385 WARN [P=945455:O=0:CT] org.hibernate.util.JDBCExceptionReporter - SQL Error: 1400, SQLState: 23000
2006-05-18 18:54:03,385 ERROR [P=945455:O=0:CT] org.hibernate.util.JDBCExceptionReporter - ORA-01400: cannot insert NULL into ("RZBBCO"."CLASHEETRATIO"."SECTION_ID")

2006-05-18 18:54:03,385 WARN [P=945455:O=0:CT] org.hibernate.util.JDBCExceptionReporter - SQL Error: 1400, SQLState: 23000
2006-05-18 18:54:03,385 ERROR [P=945455:O=0:CT] org.hibernate.util.JDBCExceptionReporter - ORA-01400: cannot insert NULL into ("RZBBCO"."CLASHEETRATIO"."SECTION_ID")


2006-05-18 18:54:03,385 ERROR [P=945455:O=0:CT] org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:181)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:74)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:69)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:150)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1839)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java(Compiled Code))
at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
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:730)
at at.rzb.cla.bl.MasterSheetBll.updateMastersheetBlobs(MasterSheetBll.java:179)
at at.rzb.cla.bl.MasterSheetBll$$EnhancerByCGLIB$$92124060.CGLIB$updateMastersheetBlobs$14(<generated>(Inlined Compiled Code))
at at.rzb.cla.bl.MasterSheetBll$$EnhancerByCGLIB$$92124060$$FastClassByCGLIB$$f5648a52.invoke(<generated>(Compiled Code))
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java(Inlined Compiled Code))
at at.rsf4j.core.db.hibernate.proxy.RSFHibernateInterceptor.intercept(RSFHibernateInterceptor.java(Compiled Code))
at at.rzb.cla.bl.MasterSheetBll$$EnhancerByCGLIB$$92124060.updateMastersheetBlobs(<generated>)
at at.rzb.cla.bl.MasterSheetBll.uploadMasterSheet(MasterSheetBll.java:142)
at at.rzb.cla.bl.MasterSheetBll$$EnhancerByCGLIB$$92124060.CGLIB$uploadMasterSheet$15(<generated>)
at at.rzb.cla.bl.MasterSheetBll$$EnhancerByCGLIB$$92124060$$FastClassByCGLIB$$f5648a52.invoke(<generated>)
at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:167)
at at.rsf4j.core.db.hibernate.proxy.RSFHibernateInterceptor.intercept(RSFHibernateInterceptor.java:72)
at at.rzb.cla.bl.MasterSheetBll$$EnhancerByCGLIB$$92124060.uploadMasterSheet(<generated>)
at at.rzb.cla.bl.test.CLAParseTest.testParse(CLAParseTest.java:130)
at java.lang.reflect.Method.invoke(Native Method)
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 org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)


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.