0 Replies Latest reply on Sep 28, 2005 10:11 PM by iamapony

    many-to-one lazy loading not working

    iamapony Newbie

      I have three mapped classes ApplicationImpl, ProfileImpl and ResumeImpl. Snippets of mapping documents are as follows:

       <class
       name="ApplicationImpl"
       table="APPLICATION"
       lazy="true"
       >
       <many-to-one
       name="profile"
       class="ProfileImpl"
       cascade="save-update"
       outer-join="auto"
       update="true"
       insert="true"
       column="PROFILE_OID"
       />
      ...
       <class
       name="ProfileImpl"
       table="PROFILE"
       lazy="true"
       >
       <many-to-one
       name="resume"
       class="ResumeImpl"
       cascade="save-update"
       outer-join="auto"
       update="true"
       insert="true"
       column="RESUME_OID"
       />
      ...
       <class
       name="ResumeImpl"
       table="RESUME"
       lazy="true"
       >
      


      If I run a query and return ApplicationImpl objects and read through properties on those objects, no sql is ever sent to retrieve the ProfileImpl or ResumeImpl classes as one would expect since they are lazy="true" at the class level.

      However, if on the ApplicationImpl object I call application.getProfile().getName(), a sql query is sent to the PROFILE table AND the RESUME table. It should not be quering the RESUME table if I just get a property from the ProfileImpl object. Does the system do an eager fetch if you perform a lazy initilization one level down?

      Thanks.