[jboss-jira] [JBoss JIRA] Created: (JBAS-7474) create a new persistence unit programmatically and map it to a new datasource without redeploy or server restart

Dave Chen (JIRA) jira-events at lists.jboss.org
Thu Nov 19 22:02:29 EST 2009


create a new persistence unit programmatically and map it to a new datasource without redeploy or server restart
----------------------------------------------------------------------------------------------------------------

                 Key: JBAS-7474
                 URL: https://jira.jboss.org/jira/browse/JBAS-7474
             Project: JBoss Application Server
          Issue Type: Feature Request
      Security Level: Public (Everyone can see)
          Components: Hibernate service
    Affects Versions: JBossAS-5.1.0.GA
         Environment: JBoss 5.1.0.GA
            Reporter: Dave Chen
            Assignee: Steve Ebersole


Currently we use the persistence.xml to map a persistenceUnit to data source. Our application got a requirement: 

create a new persistence unit programmatically and map it to a new datasource without redeploy or server restart. How to achieve this functionality? 

EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1");
//or
Map configOverrides = new HashMap();
configOverrides.put("hibernate.hbm2ddl.auto", "create-drop");
EntityManagerFactory programmaticEmf =
    Persistence.createEntityManagerFactory("manager1", configOverrides);

But the persistence unit "manager1" needs to be defined in persistence.xml.

What we need is:

EntityManagerFactory emf = Persistence.createEntityManagerFactory("foo", "dataSourceName");
the persistence unit "foo" is not defined in any persistence.xml.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jboss-jira mailing list