Yes, I am aware of that little snafu. I've been bitten by this one before. There is a WIKI on this one pertaining to implementing a ResultObjectFactory that can potentially correct this issue. I still need to look into it though.

http://opensource.atlassian.com/confluence/oss/display/IBATIS/Lazy+loading+issues


As it turns out the issue with Lazy Loading was not caused by the serialVersionUID being declared. Upon further research I found that someone had made a change to our base Domain object. In the constructor, some of the classes set and get public methods were being invoked. I'm guessing that the proxy class that is generated does not discriminate method calls on the object even if initialization has not been completed. For that reason, when the methods were invoked the proxy was executing the sql and loading the object. I modified the constructor to ensure that no public methods were invoked and this resolved the issue for me.





"MCCORMICK, Paul" <[EMAIL PROTECTED]>

09/11/2007 11:42 PM

Please respond to
[email protected]

To
<[email protected]>
cc
Subject
RE: Lazy Load is pre loading 1-1 relationships





Be careful with lazy loading 1-1 relationships where the lazy loaded result could be null.  A proxy object will be in its place.
 
e.g.
if ( foo.getBar() == null )  { // Bar is lazy loaded.
    // Unreachable code
}


From: Poitras Christian [mailto:[EMAIL PROTECTED]
Sent:
Wednesday, 12 September 2007 4:05 AM
To:
[email protected]
Subject:
RE: Lazy Load is pre loading 1-1 relationships


It seems that is works with my classes.
 
I don't use
private static final long serialVersionUID = -1699855014908794446L;
I use.
static
final long serialVersionUID = 7213712437136303104L;
 
Give it a try!
Christian
 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent:
Tuesday, 11 September 2007 15:57
To:
[email protected]
Subject:
RE: Lazy Load is pre loading 1-1 relationships



That was it! I removed the variable definition from all my domain objects, performed a clean and build and the lazy loading is now working correctly. Thanks for the suggestion.




[EMAIL PROTECTED]

09/11/2007 12:30 PM

Please respond to
[email protected]


To
[email protected]
cc
[email protected]
Subject
RE: Lazy Load is pre loading 1-1 relationships








This may actually answer my question. I recently added to my domain objects the following:


private
static final long serialVersionUID = -1699855014908794446L;

I added this to eliminate the warning that Eclipse was giving me. Any object that I needed to touch as of recently I would add this to. The domain objects that are not lazily loading seem to be the ones that I added serialVersionUID to.


Thanks for the help...



"Poitras Christian" <[EMAIL PROTECTED]>

09/11/2007 12:22 PM

Please respond to
[email protected]


To
<[email protected]>
cc
Subject
RE: Lazy Load is pre loading 1-1 relationships









I doubt my reply will answer your question, but this is mostly for information purpose.


All final classes are never lazy loaded by iBATIS. This include any primitive type, Strings and this like Integer, Double, etc...

This "bug" is probably due to the fact that cglib tries to extend the class. If it is final, it must be loaded now.


Christian



From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent:
Tuesday, 11 September 2007 15:12
To:
[email protected]
Subject:
Lazy Load is pre loading 1-1 relationships



I've been spending a fair amount of time on this now but I can't seem to get any further. Objects that I am attempting to load lazily are simply loading. The relationships that are 1-M seem to be fine, meaning that they are not pre-loading, but any relationship that I have that is a 1-1 seems to be loaded when the resultSet is applied to the parent object. Is there anything I can do to prevent this from happening?


Thanks...
"DISCLAIMER: This email, including any attachments, is intended only for use by the addressee(s) and may contain confidential and/or personal information and may also be the subject of legal privilege. If you are not the intended recipient, you must not disclose or use the information contained in it. In this case, please let me know by return email, delete the message permanently from your system and destroy any copies.

Before you take any action based upon advice and/or information contained in this email you should carefully consider the advice and information and consider obtaining relevant independent advice.


Reply via email to