This is how lazy="true" works today.  It always fetches the ids of the
associated objects which unfortunately for hibernate tends to mean that
you end up querying collection properties on the server twice - once to
get the ids, and once to get the values later on when you try to get the
referenced items on the client.  Partly this is so you can detect
conflicts on these properties... the client gets the entire state of the
parent object so you can see if the collection properties have been
changed before processing an update. 

 

This has been a commonly requested feature and something that we're
working to improve with a new option that just leaves collections on the
server until you access them on the client.  Ideally we will support
paging on these properties as well so we only fetch the values one page
at a time when you do access them.

 

The SequenceManager is responsible for implementing the
autoSyncEnabled=true flag.  It tracks what state is managed on each
active client and uses that information to figure out which changes each
client needs to be pushed.  It is not responsible for the id thing -
that is just how we serialize data to the client right now.

 

Jeff

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Emmanuel Potvin
Sent: Friday, October 05, 2007 1:56 PM
To: [email protected]
Subject: [flexcoders] Lazy association

 

Hi,

 

I have a class named Structure with a one-to-many association to another
class named Column. The Structure class has a property named column who
is a collection of Column. I manage this with Hibernate and my own Dao,
so I use my self coded StructureAsssembler and ColumnAssembler to access
them with the data manager of Flex.

 

In my data-management-config.xml file, I have this :

 

      <destination
id="net.cpaerp.structure.application.business.entity.Structure">

        <adapter ref="java-dao" />

        <properties>

            <use-transactions>true</use-transactions>

            <cache-items>false</cache-items>

            <auto-sync-enabled>true</auto-sync-enabled>

 
<source>net.cpaerp.structure.application.business.entity.assembler.Struc
tureAssembler</source>

            <scope>session</scope>

            <metadata>

                <identity property="id"/>

                <one-to-many property="column"
destination="net.cpaerp.structure.application.business.entity.Column"
lazy="true" sequenced="false"/>

            </metadata>

            <network>

                <session-timeout>20</session-timeout>

                <paging enabled="true" pageSize="10" />

                <throttle-inbound policy="ERROR" max-frequency="500"/>

                <throttle-outbound policy="REPLACE"
max-frequency="500"/>

            </network>

            <server>

            </server>

        </properties>

    </destination>

 

      <destination
id="net.cpaerp.structure.application.business.entity.Column">

        <adapter ref="java-dao" />

        <properties>

            <use-transactions>true</use-transactions>

            <cache-items>false</cache-items>

            <auto-sync-enabled>false</auto-sync-enabled>

 
<source>net.cpaerp.structure.application.business.entity.assembler.Colum
nAssembler</source>

            <scope>session</scope>

            <metadata>

                <identity property="id"/>

                <many-to-one property="structure"
destination="net.cpaerp.structure.application.business.entity.Structure"
lazy="true"/>

            </metadata>

            <network>

                <session-timeout>20</session-timeout>

                <paging enabled="true" pageSize="10" />

                <throttle-inbound policy="ERROR" max-frequency="500"/>

                <throttle-outbound policy="REPLACE"
max-frequency="500"/>

            </network>

            <server>

            </server>

        </properties>

    </destination>

 

As you see, my relations are < lazy >, and in some way, it works... but
not really. When I fill an AS ArrayCollection of Structure objects with
the fill method of my assembler, it return a collection of Structure,
but a SequenceManager always extract every ids of the column collection
associated with every structure extracted, before returning the
collection to the client. This makes hibernate to extract the columns
from the database without  being needed. I don't think that this is
really lazy... 

 

What is a sequence manager by the way... ?

 

Emmanuel

 

Reply via email to