Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
I have problems using Oracle when a objet have a collection of anothers and I make saveOrUpdate().
Basically, I have a worflow wich contain a step collections.
In Oracle, when it wants to save some of the passages of workflow says to me that it is not defined you go of workflow that would go in table WFSTEP (down I put the error) the error just throws it when I make tx.commit(); But the rare thing is that soon of saveOrUpdate(workflow), I logg you go of workflow and I see that exists. In addition if I inspect the object soon workflow of saveOrUpdate(), I see that everything appears ok bony it has the collection of steps and each one with his you go well seted.
Thank's for you attention.
Martin.
Hibernate version:
3.0
Mapping documents:
Workflow.hbm.xml
<bag name="wfSteps" cascade="all" lazy="true" inverse="true">
<key column="NK_WORKFLOWDEFIN" foreign-key="NK_WORKFLOWDEFIN_NK_WSTEP"/>
<one-to-many class="com.sisdam.jcs.workflow.model.WFStep"/>
</bag>
WFStep.hbm.xml
<many-to-one name="workflow" cascade="none" column="NK_WORKFLOWDEFIN" class="com.sisdam.jcs.workflow.model.Workflow" not-null="true" foreign-key="NK_WORKFLOWDEFIN_NK_WSTEP"/>
Code between sessionFactory.openSession() and session.close():
Tablas :
Workflow(idWorflow,name,etc);
WFSTEP(idStep,idWorkflow,etc);
Codigo:
Transaction tx=session.beginTransaction();
session.saveOrUpdate(workflow);
log.debug("HibernateWFPersistenceManager :: saveWorkflow() :: workflow id : " + workflow.getId());
workflow.setId(workflow.getId());
tx.commit();
Full stack trace of any exception that occurs:
java.sql.SQLException: ORA-02291: integrity constraint (ISO.REFSDMWORKFLOWDEFIN6) violated - parent key not found
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:573)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1891)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1093)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2047)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:1940)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2709)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:589)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1853)
at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
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 org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.sisdam.jcs.workflow.persistence.HibernateWFPersistenceManager.saveWorkflow(HibernateWFPersistenceManager.java:115)
at com.sisdam.jcs.workflow.service.WorkflowEngineService.saveWorkflow(WorkflowEngineService.java:412)
at com.sisdam.imp.DMS.wfDmsDefinition.DmsDefinitionToTable.<init>(DmsDefinitionToTable.java:689)
at com.sisdam.imp.DMS.wfDmsDefinition.WfDmsDefinitionHandler.executeDMSMigration(WfDmsDefinitionHandler.java:257)
at com.sisdam.imp.DMS.wfDmsDefinition.WfDmsDefinitionHandler.doImport(WfDmsDefinitionHandler.java:197)
at com.sisdam.imp.DMSDefinitionImporter.main(DMSDefinitionImporter.java:23)
09:46:31,250 WARN JDBCExceptionReporter:71 - SQL Error: 2291, SQLState: 23000
09:46:31,250 ERROR JDBCExceptionReporter:72 - ORA-02291: integrity constraint (ISO.REFSDMWORKFLOWDEFIN6) violated - parent key not found
09:46:31,265 ERROR AbstractFlushingEventListener:277 - Could not synchronize database state with session
org.hibernate.exception.ConstraintViolationException: could not insert: [com.sisdam.jcs.workflow.model.WFStep]
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:74)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: