01: //$Id: JDBCTransactionFactory.java 10013 2006-06-11 17:00:19Z gavin.king@jboss.com $
02: package org.hibernate.transaction;
03:
04: import java.util.Properties;
05:
06: import org.hibernate.ConnectionReleaseMode;
07: import org.hibernate.HibernateException;
08: import org.hibernate.Transaction;
09: import org.hibernate.jdbc.JDBCContext;
10:
11: /**
12: * Factory for <tt>JDBCTransaction</tt>.
13: * @see JDBCTransaction
14: * @author Anton van Straaten
15: */
16: public final class JDBCTransactionFactory implements TransactionFactory {
17:
18: public ConnectionReleaseMode getDefaultReleaseMode() {
19: return ConnectionReleaseMode.AFTER_TRANSACTION;
20: }
21:
22: public Transaction createTransaction(JDBCContext jdbcContext,
23: Context transactionContext) throws HibernateException {
24: return new JDBCTransaction(jdbcContext, transactionContext);
25: }
26:
27: public void configure(Properties props) throws HibernateException {
28: }
29:
30: public boolean isTransactionManagerRequired() {
31: return false;
32: }
33:
34: public boolean areCallbacksLocalToHibernateTransactions() {
35: return true;
36: }
37:
38: public boolean isTransactionInProgress(JDBCContext jdbcContext,
39: Context transactionContext, Transaction transaction) {
40: // try {
41: // // for JDBC-based transactions, we only want to return true
42: // // here if we (this transaction) are managing the transaction
43: // return transaction != null &&
44: // transaction.isActive() &&
45: // !jdbcContext.getConnectionManager().isAutoCommit();
46: // }
47: // catch ( SQLException e ) {
48: // // assume we are in auto-commit!
49: // return false;
50: // }
51: return transaction != null && transaction.isActive();
52: }
53:
54: }
|