If you mean can you lazy load individual objects held within a CPersistentCollection - no you can't (at least not at this stage). It's a good idea, but I haven't implemented it. If you want this feature, you can add a feature request for it.
Can you lazy load an entire collection? - yes you can, and it's done in the same way as you would for normal one-to-one object associations. ie set the association to retrieveAutomatic = "false" and in the property get for the collection, check if the collection is nothing. If it is then create and populate the collection using a retrieve criteria.
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've changed the framework to allow lazy loading of associations. Simpy change retrieveAutomatic to "lazy" instead of "true" and your association will be populated with proxy objects.
You then need to change your classes to handle behaviour when they are proxy objects (ie properties and associations that are not populated in a proxy object should cause the full object to be retrieved before further processing occurs).
This change is not in 2.0 RC1 so you should get the code from CVS if you want to use it.
- Richard.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Richard
Can CPersistentCollection implements lazy loading automaticly?
If not, can you show me how to implement lazy loading using CPersistentCollection?
Thank you.
If you mean can you lazy load individual objects held within a CPersistentCollection - no you can't (at least not at this stage). It's a good idea, but I haven't implemented it. If you want this feature, you can add a feature request for it.
Can you lazy load an entire collection? - yes you can, and it's done in the same way as you would for normal one-to-one object associations. ie set the association to retrieveAutomatic = "false" and in the property get for the collection, check if the collection is nothing. If it is then create and populate the collection using a retrieve criteria.
- Richard.
Hi,
I've changed the framework to allow lazy loading of associations. Simpy change retrieveAutomatic to "lazy" instead of "true" and your association will be populated with proxy objects.
You then need to change your classes to handle behaviour when they are proxy objects (ie properties and associations that are not populated in a proxy object should cause the full object to be retrieved before further processing occurs).
This change is not in 2.0 RC1 so you should get the code from CVS if you want to use it.
- Richard.
Ok!
Thank you very much!
please, any example for loading lazy with new Version 2.0 RC1
I have the following code in xml but i am getting a mistake.
<association fromClass="Logistica.Proveedor" toClass="Logistica.ProveedorMaterial" cardinality="oneToMany" target="ProveedorMateriales"
retrieveAutomatic="lazy" deleteAutomatic="false" saveAutomatic="false" inverse="false">
<entry fromAttribute="CodigoProveedor" toAttribute="CodigoProveedor" />
</association>
You need the latest CVS version to use the new lazy loading feature.
Alternatively you can wait for version 2.0 RC2 which should be released sometime this week .
- Richard.