I'm using hibernate3.2.1 with JBossCache1.3.0.SP4, deployed on WebLogic9.1.
In Java Persistence with Hibernate, it is said that '
In such a managed environment (i.e. JTA transaction service
involved), Hibernate no longer creates and maintains a JDBC connection pool - Hibernate obtains
database connections by looking up a Datasource object in the JNDI registry.' (JPwH, p. 97)
When I'm following this advice and referencing DataSource from hibernate configuration,
perstistent operations work well. But
when I tried to reference just connection URL
from hibernate configuration, no error appeared, JTATransaction logged that it '
Committed JTA UserTransaction',
but database was not affected by the insert statement at all.
I've found a similar topic at
http://forum.hibernate.org/viewtopic.php?t=942801.
Is it true that when integrated with JTA transaction service, hibernate
needs to reference datasource, not connection URL?
Second, what's the exact relationship and interaction between JTA transaction service
and DataSource? Is it the case that JTA transaction service doesn't know
what DataSource to coordinate?
Configuration
=============
A. When using datasource, the hibernate configuration looked like:
Code:
...
<property name="hibernate.connection.datasource">mydatasource</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.username">user</property>
<property name="connection.password">pwd</property>
<property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.WeblogicTransactionManagerLookup</property>
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
<property name="hibernate.cache.provider_class">org.hibernate.cache.TreeCacheProvider</property>
...
the treecache.xml:
Code:
...
<attribute name="TransactionManagerLookupClass">
org.jboss.cache.GenericTransactionManagerLookup
</attribute>
...
B. When using connection URL, the following two lines replaced the first
line from listing A:
Code:
<property name="connection.url">jdbc:oracle:thin:@//myhost:1521/myservice</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
Thanks a lot,
Veronym