Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: ORA-02292: integrity constraint violated child record found
PostPosted: Mon Mar 29, 2010 4:29 pm 
Newbie

Joined: Mon Mar 29, 2010 4:21 pm
Posts: 1
hi

I am new to hibernate and trying to implement a small example with parent -child relationship(one to many).I did set up the one to many relationship in the config files and tried to perform insert and delete operations.insert works fine it inserts child record on calling insert on parent but the delete doesn't work.When i call delete on parent it gives me the constraint violation error.Can somebody tell me what am i doing wrong.Here are the sample config files and sample code for deletion.

child.hbm.xml
Code:
<many-to-one name="Parent" column="parent_id" class="Parent" not-null="true">
</many-to-one>


parent.hbm.xml
Code:
<set name="Children" inverse="true"  cascade="all-delete-orphan" >
          <key column="parent_id"/>
          <one-to-many class="Child" />
      </set>

delete function code:
Code:
try
    {
SessionFactory sessionFactory = new Configuration()
        .configure().buildSessionFactory();
    Session session = sessionFactory.openSession();
      tx = session.beginTransaction();
      parent.getChildren().remove(child);
      session.delete(parent);
      tx.commit();
      System.out.println("Delete Successful!");
    }


this is the error i get when i delete parent
Quote:
Caused by: java.sql.BatchUpdateException: ORA-02292: integrity constraint violated - child record found

at oracle.jdbc.driver.DatabaseError.throwBatchUpdateException(DatabaseError.java:342)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePreparedStatement.java:10768)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:174)
... 9 more


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 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.