[hibernate-issues] [Hibernate-JIRA] Created: (HHH-2540) Hibernate issues inserts that cause constraint violations when using session.replicate
Scott Clasen (JIRA)
noreply at atlassian.com
Mon Apr 2 14:34:04 EDT 2007
Hibernate issues inserts that cause constraint violations when using session.replicate
--------------------------------------------------------------------------------------
Key: HHH-2540
URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-2540
Project: Hibernate3
Issue Type: Bug
Components: core
Affects Versions: 3.2.0.ga
Environment: Hibernate 3.2.0, JBPM 3.1.4, Oracle 10.2.0.2.1
Reporter: Scott Clasen
When using session.replicate to replicate a JBPM ProcessDefinition from one data store to another, hibernate does not do "the right thing" when it creates insert statements to insert the process definition into the destination data store.
There are two nullable columns with foreign keys, FK_PROCDEF_STRTSTA and FK_NODE_PROCDEF that mean ProcessDefinition must have a StartState, and a StartState must have a ProcessDefinition
here are the relevant mapping snippets.
<hibernate-mapping default-access="field">
<class name="org.jbpm.graph.def.ProcessDefinition"
table="JBPM_PROCESSDEFINITION">
<!--other mappings omitted-->
<many-to-one name="startState"
column="STARTSTATE_"
foreign-key="FK_PROCDEF_STRTSTA" />
<!--other mappings omitted-->
</class>
</hibernate-mapping>
<hibernate-mapping default-access="field">
<class name="org.jbpm.graph.def.Node"
table="JBPM_NODE"
discriminator-value="N">
<!--other mappings omitted-->
<many-to-one name="processDefinition"
column="PROCESSDEFINITION_"
foreign-key="FK_NODE_PROCDEF"/>
<!--other mappings omitted-->
</class>
</hibernate-mapping>
In the usual case of saving a ProcessDefinition, hibernate does the correct thing and inserts null for each of these foreign key columns, and then later updates these columns...like so
2007-04-02 14:22:07,863 DEBUG org.hibernate.SQL - /* insert org.jbpm.graph.def.ProcessDefinition */ insert into JBPM_PROCESSDEFINITION (NAME_, VERSION_, ISTERMINATIONIMPLICIT_, STARTSTATE_, ID_) values (?, ?, ?, ?, ?)
2007-04-02 14:22:07,863 DEBUG hibernate.type.StringType - binding 'simpleServiceDefinitionTest' to parameter: 1
2007-04-02 14:22:07,863 DEBUG hibernate.type.IntegerType - binding '3' to parameter: 2
2007-04-02 14:22:07,863 DEBUG hibernate.type.BooleanType - binding 'false' to parameter: 3
2007-04-02 14:22:07,879 DEBUG hibernate.type.LongType - binding null to parameter: 4
2007-04-02 14:22:07,879 DEBUG hibernate.type.LongType - binding '5290' to parameter: 5
2007-04-02 14:22:07,879 DEBUG org.hibernate.SQL - /* insert org.jbpm.graph.node.StartState */ insert into JBPM_NODE (NAME_, PROCESSDEFINITION_, ISASYNC_, ACTION_, SUPERSTATE_, CLASS_, ID_) values (?, ?, ?, ?, ?, 'R', ?)
2007-04-02 14:22:07,879 DEBUG hibernate.type.StringType - binding 'start' to parameter: 1
2007-04-02 14:22:07,879 DEBUG hibernate.type.LongType - binding '5290' to parameter: 2
2007-04-02 14:22:07,879 DEBUG hibernate.type.BooleanType - binding 'false' to parameter: 3
2007-04-02 14:22:07,879 DEBUG hibernate.type.LongType - binding null to parameter: 4
2007-04-02 14:22:07,879 DEBUG hibernate.type.LongType - binding null to parameter: 5
2007-04-02 14:22:07,879 DEBUG hibernate.type.LongType - binding '5291' to parameter: 6
more inserts follow and then later in the same transaction...sets the foreign key for start state.
2007-04-02 14:22:07,973 DEBUG org.hibernate.SQL - /* update org.jbpm.graph.def.ProcessDefinition */ update JBPM_PROCESSDEFINITION set NAME_=?, VERSION_=?, ISTERMINATIONIMPLICIT_=?, STARTSTATE_=? where ID_=?
2007-04-02 14:22:07,973 DEBUG hibernate.type.StringType - binding 'simpleServiceDefinitionTest' to parameter: 1
2007-04-02 14:22:07,973 DEBUG hibernate.type.IntegerType - binding '3' to parameter: 2
2007-04-02 14:22:07,973 DEBUG hibernate.type.BooleanType - binding 'false' to parameter: 3
2007-04-02 14:22:07,973 DEBUG hibernate.type.LongType - binding '5291' to parameter: 4
2007-04-02 14:22:07,973 DEBUG hibernate.type.LongType - binding '5290' to parameter: 5
When using session.replicate to copy a fully initialized object from a source to a destination data store...hibernate does not set the start state to null and then later update...it just tries to do the insert and gets a constraint violation
2007-04-02 14:27:44,817 DEBUG org.hibernate.SQL - /* insert org.jbpm.graph.def.ProcessDefinition */ insert into JBPM_PROCESSDEFINITION (NAME_, VERSION_, ISTERMINATIONIMPLICIT_, STARTSTATE_, ID_) values (?, ?, ?, ?, ?)
2007-04-02 14:27:44,817 DEBUG hibernate.type.StringType - binding 'simpleServiceDefinitionTest' to parameter: 1
2007-04-02 14:27:44,817 DEBUG hibernate.type.IntegerType - binding '70' to parameter: 2
2007-04-02 14:27:44,817 DEBUG hibernate.type.BooleanType - binding 'false' to parameter: 3
2007-04-02 14:27:44,817 DEBUG hibernate.type.LongType - binding '5553' to parameter: 4 //This should be null, and then later updated
2007-04-02 14:27:44,817 DEBUG hibernate.type.LongType - binding '5552' to parameter: 5
2007-04-02 14:27:44,832 WARN hibernate.util.JDBCExceptionReporter - SQL Error: 2291, SQLState: 23000
2007-04-02 14:27:44,832 ERROR hibernate.util.JDBCExceptionReporter - ORA-02291: integrity constraint (JBPM.FK_PROCDEF_STRTSTA) violated - parent key not found
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list