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.  [ 4 posts ] 
Author Message
 Post subject: Mass object creation on collection operations.
PostPosted: Thu Dec 30, 2004 7:30 am 
Newbie

Joined: Fri Dec 24, 2004 4:09 am
Posts: 11
I have following tables and corresponding classes with appropriate get/set methods for all fields.

ITEMS
ID

ORDER
ID
ITEM_ID
CUSTOMER_ID

CUSTOMERS
ID
Code:
class Item{
   privater long id;   
   ...
   private Set orders;
   /* hibernate.set table = "ORDER" cascade = "all-delete-orphan" lazy = "true" inverse =    "true" */
   public Set getOrders(){
      return orders;
   }
   ...
}

class Order{
   privater long id;   
   private Item item;
   private long customer_id;
   ...
}

class Customer{
   privater long id;
   private Set orders;
   /* hibernate.set table = "ORDER" cascade = "all-delete-orphan" lazy = "true" inverse =    "true" ...*/
   public Set getOrders(){
      return orders;
   }

   ...
}


when I do

Code:
//hibernate doesn't create Orders objects (because lazy initialization was set to true)   
Set orders = customer.getOrders();

//hibernate create all orders that customer have before adding newOrder
orders.add(newOrder);

is there any way to make hibernate not create all orders objects in memory?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 30, 2004 7:45 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
try a bag

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 30, 2004 8:08 am 
Newbie

Joined: Fri Dec 24, 2004 4:09 am
Posts: 11
anthony wrote:
try a bag


As far as I know bag is an unordered collection that permits _duplicate_ elements.

unfortunately my model doesn't allow to customer to have two equal orders

is there any other solution for my problem?

PS Many thanks for quick replay! ;-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 30, 2004 11:17 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Read the FAQ on collectino performance in the reference guide.
Then chose the best for you

_________________
Emmanuel


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