[ 
https://issues.apache.org/jira/browse/IBATIS-596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12708538#action_12708538
 ] 

Kai Grabfelder commented on IBATIS-596:
---------------------------------------

Sounds like an interesting feature. Could you add a testcase against the 
current trunk? An updated iBATIS-SqlMaps-2_en.sxw file documenting your change 
would also be great.

> Null-References for sub selects with lazy loading
> -------------------------------------------------
>
>                 Key: IBATIS-596
>                 URL: https://issues.apache.org/jira/browse/IBATIS-596
>             Project: iBatis for Java
>          Issue Type: Improvement
>          Components: SQL Maps
>    Affects Versions: 2.3.4
>            Reporter: Stefan Gmeiner
>             Fix For: 2.3.5
>
>         Attachments: null-proxy.patch
>
>
> We are using the iBatis enhanced (cglib) proxy for lazy loading our 
> sub-select bean references.
> Unfortunately if a reference is null iBatis creates a proxy with
> null content. This makes using lazy loading less transparent to clients as 
> they are required
> to execute further checks to see if the returned object is null.
> Hence we are suggesting a simple solution which is attached as a patch:
> A proxy for a lazy loaded object is now only created if the foreign key is 
> non-null.
> When using the curly braces syntax (parameter map) a postfix '?' is required 
> to activate
> the new lazy loading otherwise the existing strategy is used. This allows for 
> the possibility
> of subselects requiring a null value as foreign key.
> Example:
> <result property="jobs" column="job_pk" select="selectJob"/>
> This will return null if job_pk is null and a proxy for the job is job_pk is 
> not null.
> <result property="jobs" column="{transportIdentifier=job_pk}" 
> select="selectJob"/>
> This will always return a proxy object irrespective of the job_pk value.
> <result property="jobs" column="{transportIdentifier=job_pk?}" 
> select="selectJob"/>
> This will return null if job_pk is null and a proxy for the job is job_pk is 
> not null.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to