Menu

Question about lazy loading

2004-10-26
2013-03-07
  • Nobody/Anonymous

    Hello Richard

    Can CPersistentCollection implements lazy loading automaticly?
    If not, can you show me how to implement lazy loading using CPersistentCollection?

    Thank you.

     
    • Richard Banks

      Richard Banks - 2004-10-26

      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.

       
    • Richard Banks

      Richard Banks - 2004-11-01

      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.

       
    • Nobody/Anonymous

      Ok!

      Thank you very much!

       
    • Victor SAquicela

      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>

       
      • Richard Banks

        Richard Banks - 2004-11-07

        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.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.