I am having trouble getting WLS 8.1 container-managed transactions to work correctly with Hibernate 2.1 and an Oracle 9.2 database. My application is a simple "test app" bundled with the jBpm workflow engine (
http://jbpm.org). Stateful and stateless session beans provide business services, invoking Hibernate to perform persistence operations while relying upon the WLS container to manage transactions.
The default configuration is for Hibernate use a WLS-managed datasource (see below). I initially configured WLS with a datasource and connection pool using the OracleXADataSource driver class. This worked fine except that Hibernate fails when inserting BLOBs larger than 4000 bytes due to a well-known problem with how Oracle's JDBC drivers handle LOBs (
http://www.hibernate.org/56.html).
<!-- Hibernate config to use a WLS-managed datasource -->
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="connection.datasource">JbpmDS</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
In order to implement the Oracle JDBC workaround, I configured Hibernate to directly connect to Oracle (see below) because I could not find any way to unwrap the WLS JDBC wrappers to get at the underlying wrapper objects. WLS 8.1 dynamically creates wrappers for all JDBC objects, but this foils Oracle when invoking Oracle-specific APIs like BLOB.createTemporary() with a WLS-wrapped Connection.
<!-- Hibernate config to directly manage Oracle connections -->
<property name="transaction.manager_lookup_class">net.sf.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="dialect">net.sf.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.driver_class">oracle.jdbc.xa.client.OracleXADataSource</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:NBOYDLAP</property>
However, configuring Hibernate to connect directly to Oracle thwarts WLS container-managed transactions: based on the logs, Hibernate executes many database statements, but they are never committed by the container.
In summary, I need help to:
1. Configure WLS container-managed transactions to work correctly with a Hibernate session factory that directly opens and manages Oracle connections.
-or-
2. Figure out how to *really* unwrap WLS-wrapped JDBC connections and statements so that I can use the Oracle-specific BLOB API.
Thanks in advance for tips or other suggestions!
- nate