I'm not sure about the best practices related to this, but I spent a lot of time doing something like this work.
Basically you need to build something EntityManagerwith. I have always used Spring for this. Their documentation documentation ):
<bean id="myEmf" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="myPersistenceUnit"/>
</bean>
, , , , , . , , - .
hibernate (persistence.xml META-INF/):
<property name="hibernate.connection.driver_class" value="com.company.driver" />
<property name="hibernate.connection.url" value="some:jdbc@string" />
<property name="hibernate.connection.username" value="myuser" />
<property name="hibernate.connection.password" value="mypassword" />
, Spring, EntityManagerFactory (.. context.getBean("myEmf")).
LocalContainerEntityManagerFactoryBean , . , , , , Hibernate. persistence.xml, (, , , oracle 10g):
<bean id="emf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="myDatasource" />
<property name="persistenceProvider">
<bean class="org.hibernate.ejb.HibernatePersistence" />
</property>
</bean>
Spring BasicDataSource Apache dbcp, .
, JPA . , , Hibernate JPA, , , JPA. , API- Hibernate.