0 Replies Latest reply on Sep 22, 2009 10:23 PM by gimpy21

    What's the proper way to 'cache' a large update operation until session.flush() is called?

    gimpy21

      I have a LRC with its flush mode set to manual. The user can perform actions on a page that will lead to an update statement needing to be executed to modify an association. (I need this to avoid a potentially large set of entities from being loaded into memory for a single column update.) I need this to be atomic with the rest of the conversation. Is there a way to make a call, such as 'session.createQuery(update ...).executeUpdate()' that will be 'cached' until session.flush() is called? (It currently runs immediately and will not roll back if an error occurs later within the conversation.) Is there a better way to do this?


      I'm using an injected delegate (a Hibernate Session).


      From components.xml:


      <persistence:managed-persistence-context name="entityManager"
       auto-create="true"
       persistence-unit-jndi-name="java:/SampleEntityManagerFactory"/> 
         
         <factory name="session"
               scope="STATELESS"
               auto-create="true"
               value="#{entityManager.delegate}"/>