When retrieving a 1:1..0 mapping using proxies, after counting how many values has in the table, OJB should set the referenced object to NULL when counting is 0 (not setting the reference for a proxy that will give a NPE when trying to call a method).
If the value set is a proxy (event if will never have a value there, since count is 0) the following statement always goes to else section, and gives a NPE:
// The following test is always false, because until now, myReferencedObject is a reference to a proxy.
// But the select count(*) returned 0.
if( myObject.myReferencedObject==null ) {
System.out.println("There is no reference");
} else {
System.out.println("There is reference!");
System.out.println("myObject.myReferencedObject.getId() = " + myObject.myReferencedObject.getId());
// the previous line will throw a NPE, because when materializing, it return NULL!!!
}
Is possible to fix this? There is one workaround, map all 1:0..1 mappings as collections and does internal treatment to them, or not use Proxy for 1:0..1 mappings (that will set value to NULL when there is no referenced object - as expected).
Thanks,
Edson Richter
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
