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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Larry Meadors
Sent: woensdag 24 januari 2007 13:26
To: user-java@ibatis.apache.org; [EMAIL PROTECTED]
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 <[EMAIL PROTECTED]> 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:[EMAIL PROTECTED] 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
> >
> >
>
>

Reply via email to