You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by "Haulyn R. Jason" <sa...@gmail.com> on 2008/08/12 06:03:21 UTC

IBatis 2.3 lazy loading issue for return null instead of an list

Hi,
I use the feature Lazy loading for IBatis2.3, I have a domain class like:
public class Role(){
private String id;
private String name ;
private List<Privilege> privilegeList ;
}

the problem is:
when the privilegeList is not null, I mean a Role object has more than
one Privilege, ok, everything goes well.
But when the Role doesn't has any Privilege, I hope my Dao could return
null for the property privilegeList. When I debug my program, I found
it's stranger, the privilegeList is not null, it is a List with one
element, the only one element is Privilege Object but doesn't have values.

I try to google the issue and find this:
http://opensource.atlassian.com/confluence/oss/display/IBATIS/Lazy+loading+issues
but I really can not understand how can I achieve my goal.

Always thanks for solution or some urls reference.

-- 

Thanks!

Mobile: +086-15864011231
EMail&gtalk:saharabear@gmail.com
EMail&yahoo:jia_haolin@yahoo.com
Skype:saharabear


贾昊林(Haulyn Runner Jason)


Re: IBatis 2.3 lazy loading issue for return null instead of an list

Posted by Nicholoz Koka Kiknadze <ki...@gmail.com>.
AFAIK the root of the problem is that when iBatis handles resultset of left
joining master table with child table the child table columns may be all
NULL and it's not quite clear whether child table indeed contained
corresponding row with NULL elements or there was no result found in the
child table. Hence it adds a single element (with NULL values) to the list.
So i think it's not lazy loading issue at all.

Hence in such situations I add a check in my DAO layer and discard the child
list if it contains single element with all NULL values. Wish iBatis could
handle this for me through, say, some boolean flag 'discardNullChildLists'.



2008/8/12 Haulyn R. Jason <sa...@gmail.com>

> Hi,
> I use the feature Lazy loading for IBatis2.3, I have a domain class like:
> public class Role(){
> private String id;
> private String name ;
> private List<Privilege> privilegeList ;
> }
>
> the problem is:
> when the privilegeList is not null, I mean a Role object has more than
> one Privilege, ok, everything goes well.
> But when the Role doesn't has any Privilege, I hope my Dao could return
> null for the property privilegeList. When I debug my program, I found
> it's stranger, the privilegeList is not null, it is a List with one
> element, the only one element is Privilege Object but doesn't have values.
>
> I try to google the issue and find this:
>
> http://opensource.atlassian.com/confluence/oss/display/IBATIS/Lazy+loading+issues
> but I really can not understand how can I achieve my goal.
>
> Always thanks for solution or some urls reference.
>
> --
>
> Thanks!
>
> Mobile: +086-15864011231
> EMail&gtalk:saharabear@gmail.com <EM...@gmail.com>
> EMail&yahoo:jia_haolin@yahoo.com <EM...@yahoo.com>
> Skype:saharabear
>
>
> 贾昊林(Haulyn Runner Jason)
>
>