6 Replies Latest reply on Oct 20, 2005 2:58 AM by Martin Heinemann

    How does FetchType.LAZY affects Entities called by a client?

    Martin Heinemann Newbie

      Hi,

      i'm wondering how the fetchtype LAZY affects Entities which are requested by a client through an SessionBean.
      I build some samples to figure out how this works.
      All my Entities are marked with fetch=FetchType.LAZY. There are some n2m, one2m relations.
      I wrtoe a SessionBean which requests an entity and requests the related entities from the n2m relations.
      The logfiles from my PostgresSQL told me, that there is a SQL Query to get the root entity and when the session bean runs the second call, the dependent entities are requested from the database. Fine, thats how i expected this.

      My question:
      I got an client, calling a method on the session been which returns a reference to the entity bean. On this entity im calling the same operations as the SessionBean has done befor in the container.
      The database log shows only one initial query for the whole relation tree.
      So, does the FetchType.LAZY affects the entities used by clients?
      I guess not.