2 Replies Latest reply on Nov 30, 2012 11:34 AM by tom_goring

    Seam persistence and flush mode

    andrewwheeler

      I'm tinkering with seam persistence (Beta1). The documentation is a little light on how to set the flush mode to manual. I tried using a managed bean (@Named, not @ManagedBean) but after calling a method from my JSF page using ajax the transaction is flushed causing validation errors.


      The documentation just stops with TODO: The next section needs to be updated to seam 3. and has copied verbatim from the seam 2 manual.


      Also, if it hasn't been considered perhaps the default behavior could be manual flush. Would it be appropriate to set this as an attribute of @SeamManaged(flushMode=FlushModeType.MANUAL)? Of course this could be over-ridden on each bean.


      When combining EJB session beans and CDI managed beans should the session bean @Inject the seam managed entityManager or use the @PersistenceContext annotation?


      When injecting the seam managed entityManager into beans other the @ConversationScoped such as @RequestScoped what are the implications given that the seam managed provider is scoped as @ConversationScoped as in the following code:


      @SeamManaged
      @Produces 
      @PersistenceUnit 
      @ConversationScoped
      EntityManagerFactory entityManagerFactory;
      



            

        • 1. Re: Seam persistence and flush mode
          blabno

          I've just hit the same problem.

          You can set default flush mode in beans.xml (or seam-beans.xml):

           

              <persistence:FlushModeManagerImpl>

                  <persistence:flushModeType>MANUAL</persistence:flushModeType>

              </persistence:FlushModeManagerImpl>

           

          (xmlns:persistence="urn:java:org.jboss.seam.persistence")

           

          Or programatically by injecting FlushModeManager and invoking setFlushModeType..

          • 2. Re: Seam persistence and flush mode
            tom_goring

            Hi Bernard,

             

            thanks for this link.

             

            Couple of questions:

             

            1) If I add the above to my beans.xml I get

            cvc-complex-type.2.4.a: Invalid content was found starting with element 'persistence:FlushModeManagerImpl'. One of '{"http://java.sun.com/xml/ns/

            javaee":decorators, "http://java.sun.com/xml/ns/javaee":alternatives}' is expected.

            could you provide a full example?

             

            2) If I want to set flush mode manual programtically for all my entity managers where should I do this? (I've done it on a interceptor on my service layer which works).

             

            3) Flush Mode Manual still requires me in my service layer call flush on the entity manager.  I want this to auto happen for me when the conversation completes.

            How should I go about this ? can I listen to the conversation ending generically ?

             

             

            Thanks in advance.