01: /*
02: *
03: * (c) Copyright 2004 - 2007 osbl development team.
04: *
05: * This file is part of con:cern (http://concern.sf.net).
06: *
07: * the osbl is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.osbl;
15:
16: import org.concern.controller.*;
17: import org.conform.hibernate.HibernateEnvironment;
18: import org.hibernate.*;
19: import org.apache.commons.logging.LogFactory;
20:
21: import javax.transaction.TransactionManager;
22:
23: /**
24: * @author hengels[at]mercatis[dot]de
25: * @version $Revision: 1.7 $
26: */
27: public class JTAHibernateEnvironment extends HibernateEnvironment {
28: private static org.apache.commons.logging.Log LOG = LogFactory
29: .getLog(HibernateEnvironment.class);
30:
31: private Transactions transactions = new Transactions();
32:
33: public JTAHibernateEnvironment() {
34: }
35:
36: public void setTransactionManager(
37: TransactionManager transactionManager) {
38: this .transactions.setTransactionManager(transactionManager);
39: }
40:
41: public void beginTransaction() throws HibernateException {
42: LOG.debug("BEGIN TRANSACTION");
43: transactions.beginRequired();
44: }
45:
46: public void setSetRollbackOnly(boolean b) {
47: LOG.debug("MARK TRANSACTION ROLLBACK ONLY");
48: transactions.setRollbackOnly();
49: }
50:
51: public void endTransaction() throws HibernateException {
52: LOG.debug("END TRANSACTION");
53: transactions.endRequired();
54: }
55:
56: public Transactions getTransactions() {
57: return transactions;
58: }
59:
60: public void ensureTransactionClosed() {
61: if (transactions.getPropagationNesting() != 0)
62: LOG.warn("Transaction still active. Propagation Nesting: "
63: + transactions.getPropagationNesting());
64: }
65: }
|