-->
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: Bidirectional one-to-many performance problem
PostPosted: Sat Jun 26, 2004 9:15 am 
Beginner
Beginner

Joined: Thu Jun 10, 2004 6:52 am
Posts: 29
I have a bidirectional assoc one-to-many from User to Order. When I was trying to populate the database to see how it works with some data in it, I found that after several hundred orders (2 or 3 hundreds) for a user, adding an order to the order collection of a user takes 300, 400 msec. on a PIV 2GHZ Win XP, hibernate 2.1.4 on Win XP. The time spent loading the entire order collection of orders for the user before adding the order to it:

Order order = new Order();
order.setUser(user);
user.getOrders().add(order);
session.save(order);

Is there a way to avoid this, or to optimize it ? 300, 400 msec is quite a time for an insert isn't it ?

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jun 26, 2004 10:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Read the FAQ.

http://www.hibernate.org/117.html#A9


Top
 Profile  
 
 Post subject: Thanks
PostPosted: Sat Jun 26, 2004 4:49 pm 
Beginner
Beginner

Joined: Thu Jun 10, 2004 6:52 am
Posts: 29
I gues the answer, as i have the relationship mapped as a many-to-one inverse=true, is do not make getOrders().add(order), order.setUser(user) and save(order) is enough if i want just to insert the order.

Please, reply only if I'm wrong. Sometimes I'm amazed how i can't see the forest because of the trees.


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.