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: enhancementEnabled and lazyLoadingEnabled problem.
Date Mon, 25 Sep 2006 06:35:04 GMT
I once answered something like this, see
http://www.mail-archive.com/user-java@ibatis.apache.org/msg01481.html

Maybe the developers can comment on this one, since the original thread
lacks their opinion.

 

Niels

 

________________________________

From: MCCORMICK, Paul [mailto:Paul.McCORMICK@doir.wa.gov.au] 
Sent: maandag 25 september 2006 5:55
To: user-java@ibatis.apache.org
Subject: enhancementEnabled and lazyLoadingEnabled problem.

 

I have set enhancementEnabled="true" and lazyLoadingEnabled="true" in
the SqlMapConfig 

A problem exists when the lazy loaded object is null.  Using the
enhancementEnabled="true" option causes enhanced lazy loaded object to
be returned from a getter even if the lazy query returned no rows.
Calling any method on the enhanced object causes a null pointer
exception.

For example.  There is a 1 to 0..1 relationship between Foo and Bar.  
Class Foo { 
  private Bar bar;  
  ... 
} 

// Now here is the test that fails if set enhancementEnabled="true" 
Foo foo = (Foo)queryForObject("fooWithNullBar", null); 
Bar bar = foo.getBar(); 
assertTrue(bar == null);  // FAILS!!! 

If enhancementEnabled="false"  then the test work.  Is this a bug or
have I misunderstood enhancementEnabled what the flag does?   I'm using
version 2.2.0.636.

Thanks, 
Paul 

"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.
	

Mime
View raw message