-->
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: Getting problem with one-to-many related SQL
PostPosted: Wed Jan 28, 2004 5:56 am 
Newbie

Joined: Thu Sep 18, 2003 1:50 am
Posts: 17
Hello everybody!

I am working on a big project. The database is designed in the beginning without considering Hibernate concerns. Now we are using Hibernate for automated persistence. I am facing this problem with CMR. I am using cascade=all with one-to-many relation in Source entity mapping. When I am saving source entity Hibernate is generating
i) INSERT query for SOURCE entity
ii) generating INSERT query for TARGET entities (without SOURCE-ID value)
iii)then generating UPDATE query for updating the SOURCE-ID value

But the table defn for TARGET entity is having 'NOT NULL' constraint on SOURCE-ID column. Due to this the second query is failed in execution. Like this we have many tables defined in our system.

Is there any alternate to set the SOURCE-ID value in the INSERT query for the target without having separate UPDATE query for that.

Thank you!

_________________
- Jeevan (G1)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 28, 2004 8:15 am 
Expert
Expert

Joined: Fri Nov 07, 2003 4:24 am
Posts: 315
Location: Cape Town, South Africa
This is definitely a FAQ. Section 9.2 of the manual - bi-directional relationships - should help you. This exect topic is covered


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.