-->
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.  [ 3 posts ] 
Author Message
 Post subject: Inserting Parent and child records into database as composit
PostPosted: Mon Jan 03, 2005 4:17 pm 
Newbie

Joined: Mon Jan 03, 2005 3:31 pm
Posts: 2
Location: Plano, TX
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" />


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 23, 2005 1:09 pm 
Newbie

Joined: Thu Nov 18, 2004 4:03 pm
Posts: 7
Location: Pittsburgh,pa
I just had this problem. Check to see if you have a trigger setting the value in the db.


Top
 Profile  
 
 Post subject: Problem resolved
PostPosted: Wed Feb 23, 2005 1:19 pm 
Newbie

Joined: Mon Jan 03, 2005 3:31 pm
Posts: 2
Location: Plano, TX
I found that our database had a trigger in parent table which was changing the sequence before inserting record into a database. I removed that unnecessary trigger and it works like a charm.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

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.