0 Replies Latest reply on Mar 23, 2010 2:32 PM by ducon_lajoie

    EntityManager refresh() issues individual SELECT statements

      Hi there,

       

      I have a simple entity that is managed using JPA. It is associated in OneToMany with another entity and the FetchMode is set to SUBSELECT for that particular association.

       

      I have found that a call to EntityManager.find() will issue 2 SELECT statements: one for the main entity and one with a subselect for its association, which is what I want.

       

      However, upon an update, I usually to the following:

      {code}

      MyDTO test = myEntityManager.merge(aDTO);

      myEntityManager.flush();

      myEntityManager.refresh(test);

      {code}

       

      But in that case, the refresh will issue individual SELECT statements for each instance of my object's associated objects. Is there any way to make this work just like with a find()?

       

      Thanks,

       

      Greg