ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Niels Beekman" <n.beek...@wis.nl>
Subject RE: Odd behavior with CGLIB (lazy loading problem)
Date Wed, 24 Jan 2007 12:34:13 GMT
We ran into this issue by trying to reuse parameter validation code. It
can be worked around, but it's still something to be aware of (maybe on
the Wiki?).

Paul has a slightly different problem I think, since our method calls
triggered lazy loading, while Paul cannot load the data at all, if I'm
not mistaken.

Niels

-----Original Message-----
From: larry.meadors@gmail.com [mailto:larry.meadors@gmail.com] On Behalf
Of Larry Meadors
Sent: woensdag 24 januari 2007 13:26
To: user-java@ibatis.apache.org; pbenedict@apache.org
Subject: Re: Odd behavior with CGLIB (lazy loading problem)

Why would you call the setter on a field defined in the class?

Larry


On 1/23/07, Paul Benedict <pbenedict@apache.org> wrote:
> Clinton,
>
> I have a working example that I can email to you if you're interested.
> Can I email it? Here's a clearer explanation of what Niels and I are
> experiencing:
>
> I have two classes: A which holds an instance of B. I have enhanced
lazy
> loading turned on and I query for A with B being lazily loaded. The
> inner callback object which proxies B has a "loaded" boolean property
(I
> mistakenly called this "initialized" in the previous email) which
> indicates whether the inner object has been truly loaded or needs to
> execute the query.
>
> If B calls any internal methods in the constructor, which may be
> expected due to data initialization, then "loaded" is immediately
marked
> as "true" and the query never executes.
>
> Paul
>
> Niels Beekman wrote:
> > We had exactly the same issue, calling a method from within the
> > constructor triggers "lazy" loading, which obviously isn't very lazy
> > anymore.
> >
> > We ended up adding enhancer.setInterceptDuringConstruction(false)
where
> > an Enhancer-object is constructed (2 times in
EnhancedLazyResultLoader).
> >
> > This could however cause problems when you are accessing
uninitialized
> > variables (not loaded from DB), but we're fine with that.
> >
> > HTH,
> >
> > Niels
> >
> > -----Original Message-----
> > From: Paul Benedict [mailto:paulus.benedictus@gmail.com] On Behalf
Of
> > Paul Benedict
> > Sent: dinsdag 23 januari 2007 5:05
> > To: User Ibatis
> > Subject: Odd behavior with CGLIB
> >
> > Can someone tell me if this is a bug in iBATIS:
> >
> > I turned on lazy loading of a class. In the constructor of the
object, I
> >
> > called a protected method to initialize some properties. Example:
> >
> > public MyClassConstructor() {
> >    setId(-1);
> > }
> >
> > Because I called a method, iBATIS marked this class has "loaded" but
it
> > was never really loaded. Only by replacing setId(-1) with this.id =
-1;
> > was I able to prevent the "loaded" variable from being immediately
set.
> >
> > I believe there is some sort of sequencing error here. The class
should
> > not be considered initialized until after the constructor returns.
> > Thoughts?
> >
> > Paul
> >
> >
>
>

Mime
View raw message