-->
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.  [ 11 posts ] 
Author Message
 Post subject: 3.1rc3 - default lazy="false"! how comes?
PostPosted: Thu Nov 24, 2005 7:44 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
we are in the process of migrating our app from 3.0.5 to 3.1rc3

a major issue is that hibernate rc3 appears to operate in default lazy mode = false!

--> all associations are being loaded resulting in tremendous overhead!

Is this intended? Or any change in SessionFactory settings needed to explicitly enable default lazy = true ?


Top
 Profile  
 
 Post subject: why 3.1 branch loading whole object graph?
PostPosted: Thu Nov 24, 2005 12:46 pm 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
I tried to explicitly configure lazy="true" for all collections,

but this hibernate release 3.1rc3 always loads the whole object graph!

Some hundred selects are executed.

This never happened with 3.0.5.

Anbody there having an idea what change in the 3.1 branch is causing this?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 1:28 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
can isolate the problem down to two mapping files and a some java code? you have probably overlooked some small detail.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 1:35 pm 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
dennisbyrne wrote:
can isolate the problem down to two mapping files and a some java code? you have probably overlooked some small detail.


well, as I said, the lazy loading works properly with hibernate 3.0.5

The problem occured after replacing jar with 3.1rc3

What I tried now was explicitly stating:
<hibernate-mapping default-lazy="true">
in the file containing mapping class which is queried.
Also in the mapping class definition I added lazy="true".

It appears 3.1rc3 is completely ignoring any lazy setting. It loads the whole related object graph.

I wonder what is causing hibernate to disable the lazy loading completely...

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 1:42 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
so can isolate the problem down to two mapping files and a some java code ... but your just teasing us? oh, the suspense.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 1:55 pm 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
dennisbyrne wrote:
so can isolate the problem down to two mapping files and a some java code ... but your just teasing us? oh, the suspense.


I don't know how the problem could be isolated really as it appears to be generic.
It must be due to some code change in the 3.1 branch. I browsed JIRA for an hour for a relating issue but could not find anything that applies to the matter...

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 24, 2005 2:03 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
if the problem is as you describe then it should not take you long to put this in a small junit test.

I promise to run it in my environment if you are still getting the problem. But I am quite sure there is some minor oversight here.


Top
 Profile  
 
 Post subject: has HQL-fetch implementation changed?
PostPosted: Fri Nov 25, 2005 6:28 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
ok, another approach to locate the problem is that maybe the HQL implementation has changed:
the HQL which is causing the undesired select-statements is using HQL's fetch notation

HQL-statement (simplified):

Code:
from VtVertragsinstanz as mainTable
left join fetch mainTable.kundenbetreuerStPerson as A
left join fetch mainTable.vtVertragsinstanzKundes as B
where mainTable.id=?


what should hibernate do: load a pojo-graph that includes
    - the requested instance of mainTable
    - all associated A-instances
    - all associated B-instances
hibernate 3.0.5 did this job.

what is hibernate 3.1rc loading:
    - the requested instance of mainTable
    - all associated A-instances
    - all associated B-instances
    - load ALL associations related to a A, ignoring any lazy-setting (bad!)
    - load ALL associations related to a B, ignoring any lazy-setting (bad!)



please some developer of 3.1rc3 branch comment on this. I'd be grateful.

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject: how implementing LoadEventListener ?
PostPosted: Fri Nov 25, 2005 7:22 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
ok, as expected the HQL is not causing the trouble, neither the lazy config.

The actual cause is a newly registered CustomLaodEventListener:

public class LoadingListener extends DefaultLoadEventListener
{
public void onLoad(LoadEvent event, LoadType loadType)
throws HibernateException
{
super.onLoad(event, loadType); <<--- this is causing the undesired lazy loadings

pojo = event.getResult();
mycode...
}

If I don't call super.onLoad() event.getResult() will ALWAYS be null and hence I cannot do any operation on the pojo.

Is anybody out there who has successfully implemented LaodEventListener doing operations on the pojo ?

_________________
Please don't forget to give credit, if my posting helped to solve your problem.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 25, 2005 8:18 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The event listener has changed in Hibernate 3.1
you can register several listeners per event. This might be your problem

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 25, 2005 11:29 am 
Senior
Senior

Joined: Mon Aug 22, 2005 5:45 am
Posts: 146
yes, I know, I did also try to pass first the DefaultLoadEventListener and then my CustomLoadEventListener, which did result in the same lazy loading trouble.

Finally I figured out that for our purpose the post-load event listener is more suitable. I implemented a custom PostLoadEventListener and everything works fine.

thanks, Emmanuel, anyway, for your input.


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