4 Replies Latest reply on Apr 5, 2008 4:57 PM by Pete Muir

    Multiple Persistence Managers

    Petterson Paula Newbie

      Hello,


      I need to create two Persistence Managers, one for persisting an audit entry for every non-handled error that happens, and another for the rest.


      I also need that the transaction for persisting errors be isolated of the rest.


      How can I do that?


      Thanks in advance,


      Petterson

        • 1. Re: Multiple Persistence Managers
          Nicklas Karlsson Master

          Petterson Paula wrote on Feb 20, 2008 06:27 AM:


          Hello,

          I need to create two Persistence Managers, one for persisting an audit entry for every non-handled error that happens, and another for the rest.

          I also need that the transaction for persisting errors be isolated of the rest.

          How can I do that?

          Thanks in advance,

          Petterson


          Haven't done it myself buy I don't see why you couldn't just add a parallell one in components.xml and injecting the one you need

          • 2. Re: Multiple Persistence Managers
            Diego Coronel Apprentice

            this works for me:



               <persistence:managed-persistence-context name="entityManager" auto-create="true"  >
                         <persistence:persistence-unit-jndi-name>java:/jdoctor_SegurancaEntityManagerFactory</persistence:persistence-unit-jndi-name>
                         <persistence:persistence-unit-jndi-name>java:/jdoctor_CadastrosGeraisEntityManagerFactory</persistence:persistence-unit-jndi-name>
                      <persistence:persistence-unit-jndi-name>java:/jdoctor_AmbulatorioEntityManagerFactory</persistence:persistence-unit-jndi-name>
                      <persistence:persistence-unit-jndi-name>java:/jdoctor_AlmoxarifadoEntityManagerFactory</persistence:persistence-unit-jndi-name>
               </persistence:managed-persistence-context>


            • 3. Re: Multiple Persistence Managers
              Kulvinder Singh Newbie

              how can we specify which persistence-unit-jndi-name should be used to switch to sepecifi database

              • 4. Re: Multiple Persistence Managers
                Pete Muir Master

                It should be


                <persistence:managed-persistence-context name="entityManager" auto-create="true">
                   <persistence:persistence-unit-jndi-name>java:/jdoctor_SegurancaEntityManagerFactory</persistence:persistence-unit-jndi-name>
                </persistence:managed-persistence-context>
                
                <persistence:managed-persistence-context name="entityManager1" auto-create="true">
                   <persistence:persistence-unit-jndi-name>java:/jdoctor_SegurancaEntityManagerFactory1</persistence:persistence-unit-jndi-name>
                </persistence:managed-persistence-context>



                etc.