Hello,
I am trying to insert a parent and child record in respectively Parent and Child table. Child table contains column for parent record identifier as foreign key. I am receiving integrity constraint error mentioning – parent key not found. Please see error and mapping files below:
Error:
12:46:46,415 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (DB.FK_PARENT_CHILD) violated - parent key not found
12:46:46,415 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (DB.FK_PARENT_CHILD) violated - parent key not found
12:46:46,445 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (DB.FK_PARENT_CHILD) violated - parent key not found
12:46:46,445 ERROR [JDBCExceptionReporter] ORA-02291: integrity constraint (DB.FK_PARENT_CHILD) violated - parent key not found
12:46:46,455 ERROR [JDBCExceptionReporter] Could not execute JDBC batch update
java.sql.BatchUpdateException: ORA-02291: integrity constraint (DB.FK_PARENT_CHILD) violated - parent key not found
at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:459)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:4133)
at org.apache.commons.dbcp.DelegatingStatement.executeBatch(DelegatingStatement.java:294)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:126)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2421)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2371)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2240)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
My mapping files are as follows:
Parent Mapping
<list
name="status"
inverse="true"
lazy="true"
cascade="save-update"
table="CHILD">
<key column="CHILD_IDENTIFIER" />
<index column="PARENT_IDENTIFIER" type="java.math.BigDecimal" />
<one-to-many class="Child"/>
</list>
Child mapping
<many-to-one
name="parent"
class="Parent"
not-null="true" insert="false" update="false" />
<property
name="index"
type="java.math.BigDecimal"
update="true"
insert="true"
column="PARENT_IDENTIFIER" />
|