I have an associate manyToMany, now I am Trying use automaticretrive="lazy", it is correct. But my association has a relation OneToOne with other class.
When I get a collection the object, because the objects associate a this collection don't recovery. I have retriveautomatic="true" in the OneToOne relation.
Saludos
Victor (Madrid - Spain)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For any association that is marked as retrieveAutomatic="lazy" proxy objects will be returned, and any associations from that object will not be processed.
If you retieve an object using associations like this:
A --(lazy)--> B --(auto)--> C
When you retrieve A, you will get A, and proxy versions of B, but no C's.
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
In the property you actually want something like this:
Class A
...
Property B() as B
Get
If _B.IsProxy then
_B.Retrieve()
End If
Return _B
End Get
....
End Class
Class B
...
Property C() as C
Get
If Me.IsProxy then
Me.Retrieve()
End If
Return _C
End Get
...
End Class
So now if your code is
A.Retrieve()
Console.Writeline(A.B.C.ToString)
The first line will retrieve A, and a proxy copy of B.
The second line will cause B to be retrieved (from within the A class). C will also be retrieved at this time since C is fully retrieved when B is retrieved.
The only time the lazy load option returns full objects is when one-to-one associations of the superclass are retrieved. In all other cases you should have proxy objects being returned (unless they are retrieved from the cache).
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You say:
3. One-to-Many associations can be stored in any IList based collection
dim clientes as CPersistentCollection (old)
and now
dim clientes as ArrayList (new)
Any of the two ?
Saludos
Victor (Madrid - Spain)
it is correct ???
That's right.
Obviously the CPersistentCollection includes a number of other features beyond an arraylist, but either is acceptable.
Hi,
I have an associate manyToMany, now I am Trying use automaticretrive="lazy", it is correct. But my association has a relation OneToOne with other class.
When I get a collection the object, because the objects associate a this collection don't recovery. I have retriveautomatic="true" in the OneToOne relation.
Saludos
Victor (Madrid - Spain)
For any association that is marked as retrieveAutomatic="lazy" proxy objects will be returned, and any associations from that object will not be processed.
If you retieve an object using associations like this:
A --(lazy)--> B --(auto)--> C
When you retrieve A, you will get A, and proxy versions of B, but no C's.
- Richard.
Hi,
How can I retrive object B and C ?????
In property:
if B is nothing then
b.retrive()
or
b.find()
endif
and the same to C object.
Why don't lazy option to association OneToOne doesn't run. ??????
Thanksss!!!
In the property you actually want something like this:
Class A
...
Property B() as B
Get
If _B.IsProxy then
_B.Retrieve()
End If
Return _B
End Get
....
End Class
Class B
...
Property C() as C
Get
If Me.IsProxy then
Me.Retrieve()
End If
Return _C
End Get
...
End Class
So now if your code is
A.Retrieve()
Console.Writeline(A.B.C.ToString)
The first line will retrieve A, and a proxy copy of B.
The second line will cause B to be retrieved (from within the A class). C will also be retrieved at this time since C is fully retrieved when B is retrieved.
The only time the lazy load option returns full objects is when one-to-one associations of the superclass are retrieved. In all other cases you should have proxy objects being returned (unless they are retrieved from the cache).
- Richard.
I have the following code in XML:
<class name="Cliente" table="cliente" database="erp" namespace="Ventas">
<attribute name="CodigoCliente" column="codigocliente" find="true" key="primary" />
<attribute name="Nombre" column="nombre" />
<attribute name="Apellidos" column="apellidos" />
<attribute name="Nif" column="nif" />
<attribute name="RazonSocial" column="razonsocial" />
<attribute name="FechaAlta" column="fechaalta" />
<attribute name="FormaPago" />
<attribute name="CodigoFormaPago" column="CodigoFormaPago" />
<attribute name="FormaEnvio" />
<attribute name="CodigoFormaEnvio" column="CodigoFormaEnvio" />
<attribute name="ClienteDirecciones"/>
<attribute name="CreatedDate" column="CreatedDate" timestamp="true" />
<attribute name="ModifiedDate" column="ModifiedDate" timestamp="true" />
</class>
<class name="Direccion" table="direccion" database="erp" namespace="ERP">
<attribute name="CodigoDireccion" column="codigodireccion" find="true" key="primary" />
<attribute name="TipoDireccion" column="tipodireccion" />
<attribute name="Calle" column="calle" />
<attribute name="Numero" column="numero" />
<attribute name="Piso" column="piso" />
<attribute name="Letra" column="letra" />
<attribute name="Poblacion" column="poblacion" />
<attribute name="Cp" column="cp" />
<attribute name="Provincia" column="provincia" />
<attribute name="Telefono" column="telefono" />
<attribute name="Telefonomovil" column="telefonomovil" />
<attribute name="Fax" column="fax" />
<attribute name="Email" column="email" />
<attribute name="Contacto" column="contacto" />
<attribute name="CreatedDate" column="CreatedDate" timestamp="true" />
<attribute name="ModifiedDate" column="ModifiedDate" timestamp="true" />
</class>
<class name="ClienteDireccion" table="ClienteDireccion" database="erp" namespace="Ventas">
<attribute name="CodigoCliente" column="CodigoCliente" find="true" key="primary"></attribute>
<attribute name="CodigoDireccion" column="CodigoDireccion" find="true" key="primary"></attribute>
<attribute name="Direccion" proxy="true" />
<attribute name="Cliente" />
<attribute name="CreatedDate" column="CreatedDate" timestamp="true" />
<attribute name="ModifiedDate" column="ModifiedDate" timestamp="true" />
</class>
<association fromClass="Ventas.Cliente" toClass="Ventas.ClienteDireccion" cardinality="oneToMany" target="ClienteDirecciones"
retrieveAutomatic="lazy" deleteAutomatic="true" saveAutomatic="true" inverse="false">
<entry fromAttribute="CodigoCliente" toAttribute="CodigoCliente" />
</association>
<association fromClass="Ventas.ClienteDireccion" toClass="ERP.Direccion" cardinality="oneToOne" target="Direccion"
retrieveAutomatic="true" deleteAutomatic="false" saveAutomatic="true" inverse="false">
<entry fromAttribute="CodigoDireccion" toAttribute="CodigoDireccion" />
</association>
How can I implement a lazy load ?????