-->
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: Bad performance in M:M relation with java.util.Set
PostPosted: Fri Feb 18, 2005 5:12 pm 
Newbie

Joined: Sat Jan 15, 2005 8:37 am
Posts: 2
Hi!
Using Hibernate 2.1 with latest versions of XDoclet and HSQLDB.

I have a M:M relation between two tables; statistics_tbl (mapped as StatisticsBean) and test_tbl (TestBean). The TestBean adds statistics (using a java.util.Set with lazy invokation).

Like: new TestBean().addStatistics(new StatisticsBean());

Now, it seems like all instances belonging to a perticular testBean are beeing created each time new statistics are beeing added to the Set. Each testBean may have tens of thousands of statisticsbeans, which will affect performance if all instances have to be created for each add();.

Maybe the add() method calls size() which invokes the statisticsbeans???

How to solve this?

Thanks
/Martin


Top
 Profile  
 
 Post subject: Re: Bad performance in M:M relation with java.util.Set
PostPosted: Fri Feb 18, 2005 6:11 pm 
Regular
Regular

Joined: Thu Dec 18, 2003 2:14 am
Posts: 103
Location: Brooklyn, NY
qmartek wrote:
The TestBean adds statistics (using a java.util.Set with lazy invokation).

Like: new TestBean().addStatistics(new StatisticsBean());

Now, it seems like all instances belonging to a perticular testBean are beeing created each time new statistics are beeing added to the Set.

Here's my guess (perhaps not a good one). Since it is a Set, all elements must be unique. It has to therefore test this, and the only way to test uniqueness is to load the Set. Perhaps you want a Bag for this (allows duplicates, so in some cases will be faster at inserts, but slower at updates).

See http://www.hibernate.org/hib_docs/v3/reference/en/html/performance.html#performance-collections-mostefficentinverse


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.