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. Hibernate will then attempt to locate the
UserTransaction within this resolved
InitialContext based on the namespace returned by
resolveUserTransactionName.
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.
| Modifier and Type | Field and Description |
|---|---|
| public static final String | |
| protected InitialContext | |
| private static final Logger | |
| protected String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | areCallbacksLocalToHibernateTransactions()
Implements org. |
| public void | configure(Properties
The configuration properties props)Implements org. |
| public Transaction | createTransaction(JDBCContext
The jdbc context to which the transaction belongs jdbcContext, TransactionFactory.The contract regarding the context in which this transaction will operate. transactionContextImplements org. |
| public ConnectionReleaseMode | getDefaultReleaseMode()
Implements org. |
| protected InitialContext | Returns: Value for property 'initialContext'.Getter for property 'initialContext'. |
| protected UserTransaction | Returns: The appropriateUserTransaction reference.Get the |
| protected String | Returns: Value for property 'userTransactionName'.Getter for property 'userTransactionName'. |
| public boolean | isTransactionInProgress(JDBCContext
The JDBC context jdbcContext, TransactionFactory.The transaction context transactionContext,The Hibernate transaction transaction)Implements org. |
| public boolean | isTransactionManagerRequired()
Implements org. |
| protected final InitialContext | Returns: The resolved InitialContext.The Hibernate config properties. properties)Given the lot of Hibernate configuration properties, resolve appropriate
reference to JNDI |
| protected final String | Returns: The resolvedUserTransaction namespaceThe Hibernate config properties. properties)Given the lot of Hibernate configuration properties, resolve appropriate
JNDI namespace to use for |
| DEFAULT_USER_TRANSACTION_NAME | back to summary |
|---|---|
| public static final String DEFAULT_USER_TRANSACTION_NAME | |
| initialContext | back to summary |
|---|---|
| protected InitialContext initialContext | |
| log | back to summary |
|---|---|
| private static final Logger log | |
| userTransactionName | back to summary |
|---|---|
| protected String userTransactionName | |
| JTATransactionFactory | back to summary |
|---|---|
| public JTATransactionFactory() | |
| areCallbacksLocalToHibernateTransactions | back to summary |
|---|---|
| public boolean areCallbacksLocalToHibernateTransactions() Implements org. Doc from org. Are all transaction callbacks local to Hibernate Transactions? Or can the callbacks originate from some other source (e.g. a JTA Synchronization).
| |
| configure | back to summary |
|---|---|
| public void configure(Properties props) throws HibernateException Implements org. Configure this transaction factory. Specifically here we are attempting to
resolve both an
| |
| createTransaction | back to summary |
|---|---|
| public Transaction createTransaction(JDBCContext jdbcContext, TransactionFactory. Implements org. Doc from org. Begin a transaction and return the associated Transaction instance.
| |
| getDefaultReleaseMode | back to summary |
|---|---|
| public ConnectionReleaseMode getDefaultReleaseMode() Implements org. Doc from org. Get the default connection release mode.
| |
| getInitialContext | back to summary |
|---|---|
| protected InitialContext getInitialContext() Getter for property 'initialContext'.
| |
| getUserTransaction | back to summary |
|---|---|
| protected UserTransaction getUserTransaction() Get the
| |
| getUserTransactionName | back to summary |
|---|---|
| protected String getUserTransactionName() Getter for property 'userTransactionName'. The algorithm here is
| |
| isTransactionInProgress | back to summary |
|---|---|
| public boolean isTransactionInProgress(JDBCContext jdbcContext, TransactionFactory. Implements org. Doc from org. Determine whether an underlying transaction is in progress. Mainly this is used in determining whether to register a synchronization as well as whether or not to circumvent auto flushing outside transactions.
| |
| isTransactionManagerRequired | back to summary |
|---|---|
| public boolean isTransactionManagerRequired() Implements org. Doc from org. Do we require access to the JTA TransactionManager for this strategy?
| |
| resolveInitialContext | back to summary |
|---|---|
| protected final InitialContext resolveInitialContext(Properties properties) Given the lot of Hibernate configuration properties, resolve appropriate
reference to JNDI
In general, the properties in which we are interested here all begin with
hibernate.jndi. Especially important depending on your
environment are
| |
| resolveUserTransactionName | back to summary |
|---|---|
| protected final String resolveUserTransactionName(Properties properties) Given the lot of Hibernate configuration properties, resolve appropriate
JNDI namespace to use for We determine the namespace to use by
| |