-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to map parent-child relation
PostPosted: Tue Sep 19, 2006 5:16 am 
Newbie

Joined: Mon Sep 18, 2006 9:46 am
Posts: 13
I am using Hibernate3 and Datebase is Oracle 10g

I am having two tables with parent-child relationships.

When i want to add or update a record i am getting the exception like
Constraint violationexception: cannot execute JDBC batch update

after executing the parent table.


Thanks for ur suggestions
shaik


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 19, 2006 9:03 am 
Beginner
Beginner

Joined: Thu Aug 24, 2006 6:01 am
Posts: 49
Location: sophia-antipolis, France
Hi,

It's really hard to understand exactly what your problem is, but I will take a stab at it. I believe you are saying that you have entities in one table and you have the parent-child relationship in a relationship table.

You have to be careful in this case. You must create the parent (insert it) before relating the child to it. You mustn't try to relate the parent to the child before saving the child. You mustn't try to relate the child to the parent before saving the parent. You may insert the parent, insert the child, and then create the relationship and update them. You may also insert the parent, then relate the child to the parent and insert the child.

Make sure that the child is the owner of the relationship. This means that when you insert the child with the parent related, at the moment hibernate will insert the relationship into the relationship table.

I hope that helps. I can give you real examples if you need (I just did this for a project I'm working on).

kim


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.