Title: 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.

Reply via email to