Factory for
JTATransaction
instances.
To be completely accurate to the JTA spec, JTA implementations should
publish their contextual
UserTransaction
reference into JNDI.
However, in practice there are quite a few
stand-alone
implementations intended for use outside of J2EE/JEE containers and
which therefore do not publish their
UserTransaction
references
into JNDI but which otherwise follow the aspects of the JTA specification.
This
TransactionFactory
implementation can support both models.
For complete JTA implementations (including dependence on JNDI), the
UserTransaction
reference is obtained by a call to
resolveInitialContext(Properties)
. Hibernate will then attempt to locate the
UserTransaction
within this resolved
InitialContext
based on the namespace returned by
resolveUserTransactionName(Properties)
.
For the so-called
stand-alone implementations, we do not care at
all about the JNDI aspects just described. Here, the implementation would
have a specific manner to obtain a reference to its contextual
UserTransaction
; usually this would be a static code reference, but
again it varies. Anyway, for each implementation the integration would need
to override the
getUserTransaction()
method and return the appropriate
thing.
getInitialContext
protected InitialContext getInitialContext()
Getter for property 'initialContext'.
- Value for property 'initialContext'.
getUserTransaction
protected UserTransaction getUserTransaction()
Get the UserTransaction
reference.
- The appropriate
UserTransaction
reference.
getUserTransactionName
protected String getUserTransactionName()
Getter for property 'userTransactionName'.
The algorithm here is
- Value for property 'userTransactionName'.
isTransactionInProgress
public boolean isTransactionInProgress(JDBCContext jdbcContext,
Context transactionContext,
Transaction transaction)
resolveInitialContext
protected final InitialContext resolveInitialContext(Properties properties)
Given the lot of Hibernate configuration properties, resolve appropriate
reference to JNDI
InitialContext
.
In general, the properties in which we are interested here all begin with
hibernate.jndi. Especially important depending on your
environment are
hibernate.jndi.url
and
hibernate.jndi.class
properties
- The Hibernate config properties.
- The resolved InitialContext.
resolveUserTransactionName
protected final String resolveUserTransactionName(Properties properties)
properties
- The Hibernate config properties.
- The resolved
UserTransaction
namespace