[
http://issues.apache.org/jira/browse/IBATISNET-105?page=comments#action_12329454
]
David Marzo commented on IBATISNET-105:
---------------------------------------
Sorry for the latence of my response "hard week" :-)
I updload rev04.zip with diff files created with tortoise SVN, the last old
archives can be deleted.
I create 2 new class in a new namespace IBatisNet.DataMapper.LazyLoad
LazyLoadProxyFactory:
This class is responsable to create lazy load proxies, it used in the
MappedStatement class to create lazy proxies. Also resolve the type of
the property to proxified
based on resultClass and return listClass, see
GetTypeReturnedByStatemet().
(I dont test if work in the scenario that you specify only listClass).
TODO: I think its usefull if the interceptor could be specified in a
SqlMap.config file
and let user personalize the resolution of lazy load using a custom
interceptor, of course
if none is specified use default.
TODO: I think the lazy load must perform in the same IDalSession or at
least let the user decide
if it open a new session or not but in Mapped statement I get a null session
and cant call
Build(IDalSession ...)
SimpleInterceptor: A simple implementation of an interceptro to resolve lazy
load, heavy equal to
LazyLoadList.cs
Also i Modified ReflectionInfo.cs because
http://support.castleproject.org/jira//browse/DYNPROXY-8, i Think is a bug in
DynamicProxy library, but i have
no much knowledge in reflection.
Current Issues:
Bug: http://support.castleproject.org/jira/browse/DYNPROXY-7 Resolved in SVN
an in the next version
1.1.5+
Limitation of DynamicProxies:
For proxies of class only intercept virtual methods because of you must
declare in collections the
method Count, GetEnumerator, RemoveAt .. as virutal, also its applicable
for class that is lazy load
loaded
"Problem" in lazy load 1:1 Relationship:
Scenario: Factory(Manage 0..1)<-- -->(Boss 1)Worker
tables: WORKERS(pk,name) FACTORIES(pk,fk_boss,name)
mapping:
<resultMap id="rmWorkerAll" class="Worker" >
<result property="Id" dbType="Guid" column="pk" />
<result property="Manage" dbType="Guid" column="pk" lazyLoad="true"
select="Factory.LoadAllByWorkerIdForBoss" />
<result property="Name" dbType="VarWChar" column="nombre"/>
</resultMap>
<resultMap id="rmFactoryAll" class="Factory" >
<result property="Id" dbType="Guid" column="pk" />
<result property="Boss" dbType="Guid" column="fk_boss" lazyLoad="true"
select="Worker.LoadAllById"/>
<result property="Nombre" dbType="VarWChar" column="nombre"/>
</resultMap>
Factory.Boss:
No problem the Boss property is null if the factory have no boss and also i
could optimize the
interceptor no resolving the lazy load for property Factory.Boss.Id
Worker.Manage:
Problems :-), for exaple:
if (worker.Manage != null)
{
worker.Mangage.ManufactureCar(); //ArgumentNullException
//if worker no manage a factory worker.Manage is not null because it have a
proxy
// but when resolve worker.Manage is null
}
This issue only appear in 1:1 relationships and when navigate from the
entity that have no
foreingkey in his table
Solutions:
maybe override != == operator ? its work for null ?
no use lazy load in this case ?
other ?
> Lazy load support for Strong typed collections and single Items
> ---------------------------------------------------------------
>
> Key: IBATISNET-105
> URL: http://issues.apache.org/jira/browse/IBATISNET-105
> Project: iBatis for .NET
> Type: New Feature
> Components: DataMapper, Testing
> Reporter: David Marzo
> Attachments: LazyLoad.zip, LazyLoad_rev.zip, LazyLoad_rev03.zip,
> LazyLoad_rev04.zip
>
> Nowadays Ibatis only support lazy load for no typed (IList) collections and
> can not lazy load relationship of 0 or 1.
> Changes:
> - In IBatisNet.DataMapper.Test.NUnit.SqlMapTests.ResultMapTest
> .TestLazyWithStronglyTypedCollectionMapping()
> exist one test that end ok but its outdated and it should fail.
> - BatisNet.DataMapper.Test.Domain.Order
> Ln 22:
> Original:
> private IList _lineItems;//LineItemCollection
> Correct:
> private LineItemCollection _lineItems;
> Ln: 50
> Original:
> public IList LineItems
> Correct:
> public LineItemCollection LineItems
> {...}
>
> In the statment order-with-lines-collection add to
> LazyLoad = "true"
> <resultMap id="order-with-lines-collection" class="Order"
> extends="lite-order-result-by-name" >
> <result property="LineItems" column="Order_ID"
> select="GetLineItemsForOrderWithListClass" lazyLoad="true"/>
> </resultMap>
> -TODO add test for 0...1 relationship , ej Worker.Boss
> Attached its the files changed to implement "beta" this feature
>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira