-->
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.  [ 5 posts ] 
Author Message
 Post subject: Excessive Calls to TwoPhaseLoad.initializeEntity
PostPosted: Thu Aug 21, 2008 4:11 pm 
Newbie

Joined: Thu Aug 21, 2008 3:56 pm
Posts: 3
I'm looking into performance problems for my application and found an oddity that I need help corrected. We have a POJO class that mapped to a database table that, in its basic constructor, does some initialization to the class. This initialization is fairly cheap; however, hibernate is creating thousands of proxy objects that subclass my POJO during operation, and, subsequently, is executing my initialization code too often, making it a performance problem.

So I seek to understand how I can reduce the number of proxy objects being created by hibernate:

I call add to a hibernate managed persistent set once:

org.hibernate.collection.PersistentSet.add(Object)...beneath it initializeEntity() is being called thousands of times (11,807 times)...this leads to the creation of proxy objects to my POJO thousands of times. The constructor for the generated proxy object is called the 11,807 times.
...

org.hibernate.collection.PersistentSet.add(Object) 169,753 ms Called 1 time

leads to

org.hibernate.engine.TwoPhaseLoad.initializeEntity(Object, boolean, SessionImplementor, PreLoadEvent, PostLoadEvent)
93,984ms Called 11,807 times

which leads to

com.gaic.uwd.core.dataaccess.beans.Quote$$EnhancerByCGLIB$$34910fb6.<init>()
76,562ms Called 11,807 times

Thanks,
jsfguy1234


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 21, 2008 4:31 pm 
Red Hat Associate
Red Hat Associate

Joined: Mon Aug 16, 2004 11:14 am
Posts: 253
Location: Raleigh, NC
My curiosity is piqued - can you whip up a simple JUnit or main() that demonstrates this? Paste the code & mappings here.

_________________
Chris Bredesen
Senior Software Maintenance Engineer, JBoss


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 22, 2008 2:04 am 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
I would assume that this happens because when you call add Hibernate initializes the (lazy) set and loads Quote objects that are in the database that are already part of this set.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 22, 2008 9:22 am 
Newbie

Joined: Thu Aug 21, 2008 3:56 pm
Posts: 3
[quote="nordborg"]I would assume that this happens because when you call [b]add[/b] Hibernate initializes the (lazy) set and loads Quote objects that are in the database that are already part of this set.[/quote]

There is no set with multiple quote objects - in fact there is only on quote object. Now, the quote objects contains sets of objects that have relationships to that quote object, but there is only one quote object. I definetly am not loading a set of 11,000+ quote objects.

I'm trying to come up with a unit test or main()...


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 22, 2008 10:59 am 
Newbie

Joined: Thu Aug 21, 2008 3:56 pm
Posts: 3
Turns out the profiler YourKit is broken and reporting bad results...I started stepping through code in a debugger and found TwoPhaseLoad.initializeEntity() is only being called once. The high number of calls to the Quote proxy constructor are coming from loading a large set of objects that have a relation to the Quote object...which I suppose is normal...so this is not a hibernate problem at all.


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