After setting up a data source in your AppServer, e.g. for WebLogic Server, you want to use it in your application with JPA.

Basically there are three ways to connect to a db with JPA:

  • JDBC data source with JTA transactions (not supported by a Servlet-Container like Tomcat)
  • JDBC data source with self-managed transactions, i.e. transaction-type=”RESOURCE_LOCAL”
  • direct JDBC connection

The first and second are well discussed in the www. So we give an example on the second with provider Hibernate:

<persistence-unit name="PU_ResourceLocal_WithDS" transaction-type="RESOURCE_LOCAL">

  <!-- the JNDI name as specified in your AppServer -->

    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
    <property name="hibernate.max_fetch_depth" value="5" />

For Tomcat 6 and EclipseLink this is well explained in http://wiki.eclipse.org/EclipseLink/Examples/JPA/Tomcat_Web_Tutorial.

, , , , , ,

Add reply