0 Replies Latest reply on Feb 2, 2012 5:18 PM by bram666

    seam-persistence: deployment dependant emf properties

    bram666

      Hi guys and gals,

       

      I am running into the following problem and might have overlooked something concearning the creation of a entitymanagerfactory. I'd like to have one persistence.xml and depending on the deployment use a properties file to configuere the (optional) jdbc connection and transaction attributes.

      I am currently using:

      * local development: jetty +  cdi + hibernate, so a datasource in the persistence.xml with tx attibute RESOURCE_LOCAL

      * staging: glassfish, so everything is managed in the JEE container and end up with a persistence.xml with only the persistence classes

       

      I'd like to use a shared persistence.xml with a extra properties file for local development  that i eg could configuere in the emproducer class, something like

       

      public class EntityManagerProducer {

           @Produces

           @ExtensionManaged

           @PersistenceUnit(unitname="dashboard")

           @PersistenceUnitProperties("persistence.properies")

           EntytyManagerFactory emf;

       

      }

       

      where persistence.properies contains things like "javax.persistence.jdbc.driver" if needed (could be empty or none existent)

       

      I have found the "Persistence.createEntityManagerFacotry(String puName)" in the ManagedPersistenceContextExtension that probably is used in the jetty case to setup the emf. But the "createEMFBean" method is private (cant override and plug in my extrension) in the extension and that is the place to call createEMF(name, properties) me thinks.

       

      anyways, anyone have any good idea how to do this without creating a copy of the ManagedPersistenceContextExtension ?

       

       

      regards

      Bram

       

      ps:i have found the @PersistenceProperty but that seems only be applicable for persistencecontext and not a persistenceunit,, i dont know if that works or if there are problems usinf a persistencecontext...