-->
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: number of requests with one-to-many relations
PostPosted: Wed Sep 27, 2006 1:34 pm 
Newbie

Joined: Wed Sep 27, 2006 1:15 pm
Posts: 10
Guys,

I was using Hibernate for couple years and still think it is the best O/R tool ever. However, some of my superiors does not like some facts from Hibernate. The problem comes from the number of requests sent by Hibernate when it persists related entities (one-to-many per say).

Imagine we got two types of entities - Person and Name, where person can have more than one name. So fragment of Person mapping looks like this:

Code:
<bag name="NameList" table="Name" cascade="persist,delete" >
  <key column="PersonId" />
  <one-to-many class="Name" />
</bag>


If person got two names, from proprietary SQL coding prospective there
supposed to be three requests:

insert person;
insert first name along with foreign key (person id);
insert another name along with foreign key (person id).

However, Hibernate sends 5 requests instead:

insert person;
insert first name;
insert name;
update name with foreign key (person id);
update name with foreign key (person id).


That's what my superiors do not like. So the question is if it is possible to force Hibernate to go just with 3 insertions instead of 3 insertions and 2 updates (foreign key to be inserted along with name)?

Thank you very much in advance.

CaesarDark

Environment: Hibernate 3.1.3; Sybase


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 28, 2006 1:06 am 
Regular
Regular

Joined: Tue May 16, 2006 3:32 am
Posts: 117
Use a bidirectional relationship with inverse= "true".


See:

http://www.hibernate.org/hib_docs/v3/re ... hild-bidir


Top
 Profile  
 
 Post subject: thank you very much!
PostPosted: Thu Sep 28, 2006 10:16 am 
Newbie

Joined: Wed Sep 27, 2006 1:15 pm
Posts: 10
thank you very much!


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.