Update of /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction
In directory sc8-pr-cvs1:/tmp/cvs-serv16192/net/sf/hibernate/transaction
Modified Files:
JDBCTransaction.java JDBCTransactionFactory.java
JTATransaction.java JTATransactionFactory.java
Log Message:
redesigned id generator package
applied Mark Woon's patch for generated alias lengths
minor refactoring of Transaction package
Index: JDBCTransaction.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction/JDBCTransaction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** JDBCTransaction.java 5 Jan 2003 02:11:24 -0000 1.3
--- JDBCTransaction.java 9 Jan 2003 12:24:52 -0000 1.4
***************
*** 23,26 ****
--- 23,27 ----
private boolean rolledBack;
private boolean committed;
+ private boolean begun;
private static final Log log = LogFactory.getLog(JDBCTransaction.class);
***************
*** 28,35 ****
public JDBCTransaction(SessionImplementor session) throws HibernateException {
this.session = session;
- begin();
}
! private void begin() throws HibernateException {
log.debug("begin");
--- 29,35 ----
public JDBCTransaction(SessionImplementor session) throws HibernateException {
this.session = session;
}
! public void begin() throws HibernateException {
log.debug("begin");
***************
*** 43,50 ****
--- 43,54 ----
throw new TransactionException("Begin failed with SQL exception: ", e);
}
+
+ begun = true;
}
public void commit() throws HibernateException, SQLException {
+ if (!begun) throw new TransactionException("Transaction not successfully started");
+
log.debug("commit");
***************
*** 68,71 ****
--- 72,77 ----
public void rollback() throws HibernateException {
+ if (!begun) throw new TransactionException("Transaction not successfully started");
+
log.debug("rollback");
***************
*** 101,104 ****
--- 107,111 ----
return committed;
}
+
}
Index: JDBCTransactionFactory.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction/JDBCTransactionFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** JDBCTransactionFactory.java 5 Jan 2003 02:11:24 -0000 1.3
--- JDBCTransactionFactory.java 9 Jan 2003 12:24:52 -0000 1.4
***************
*** 18,22 ****
public Transaction beginTransaction(SessionImplementor session) throws HibernateException {
! return new JDBCTransaction(session);
}
public void configure(Properties props) throws HibernateException {}
--- 18,24 ----
public Transaction beginTransaction(SessionImplementor session) throws HibernateException {
! JDBCTransaction tx = new JDBCTransaction(session);
! tx.begin();
! return tx;
}
public void configure(Properties props) throws HibernateException {}
Index: JTATransaction.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction/JTATransaction.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** JTATransaction.java 5 Jan 2003 02:11:24 -0000 1.3
--- JTATransaction.java 9 Jan 2003 12:24:52 -0000 1.4
***************
*** 37,43 ****
private final SessionImplementor session;
! private final UserTransaction ut;
! private final boolean newTransaction;
! private final boolean synchronization;
static final Log log = LogFactory.getLog(JTATransaction.class);
--- 37,44 ----
private final SessionImplementor session;
! private UserTransaction ut;
! private boolean newTransaction;
! private boolean synchronization;
! private boolean begun;
static final Log log = LogFactory.getLog(JTATransaction.class);
***************
*** 45,48 ****
--- 46,51 ----
public void commit() throws HibernateException, SQLException {
+ if (!begun) throw new TransactionException("Transaction not successfully started");
+
log.debug("commit");
***************
*** 64,67 ****
--- 67,72 ----
public void rollback() throws HibernateException {
+ if (!begun) throw new TransactionException("Transaction not successfully started");
+
log.debug("rollback");
***************
*** 83,89 ****
}
! public JTATransaction(SessionImplementor session, InitialContext context, String utName, TransactionManager transactionManager) throws HibernateException {
this.session = session;
!
log.debug("Looking for UserTransaction under: " + utName);
try {
--- 88,96 ----
}
! public JTATransaction(SessionImplementor session) {
this.session = session;
! }
!
! public void begin(InitialContext context, String utName, TransactionManager transactionManager) throws HibernateException {
log.debug("Looking for UserTransaction under: " + utName);
try {
***************
*** 125,131 ****
--- 132,143 ----
synchronization = true;
}
+
+ begun = true;
}
public boolean wasRolledBack() throws TransactionException {
+
+ if (!begun) return false;
+
final int status;
try {
***************
*** 137,141 ****
}
if (status==Status.STATUS_UNKNOWN) {
! throw new TransactionException("Could not determine transaction status", null);
}
else {
--- 149,153 ----
}
if (status==Status.STATUS_UNKNOWN) {
! throw new TransactionException("Could not determine transaction status");
}
else {
***************
*** 147,150 ****
--- 159,165 ----
public boolean wasCommitted() throws TransactionException {
+
+ if (!begun) return false;
+
final int status;
try {
***************
*** 156,160 ****
}
if (status==Status.STATUS_UNKNOWN) {
! throw new TransactionException("Could not determine transaction status", null);
}
else {
--- 171,175 ----
}
if (status==Status.STATUS_UNKNOWN) {
! throw new TransactionException("Could not determine transaction status");
}
else {
Index: JTATransactionFactory.java
===================================================================
RCS file: /cvsroot/hibernate/Hibernate2/src/net/sf/hibernate/transaction/JTATransactionFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** JTATransactionFactory.java 5 Jan 2003 02:11:24 -0000 1.3
--- JTATransactionFactory.java 9 Jan 2003 12:24:52 -0000 1.4
***************
*** 76,80 ****
public Transaction beginTransaction(SessionImplementor session) throws HibernateException {
! return new JTATransaction(session, context, utName, transactionManager);
}
--- 76,82 ----
public Transaction beginTransaction(SessionImplementor session) throws HibernateException {
! JTATransaction tx = new JTATransaction(session);
! tx.begin(context, utName, transactionManager);
! return tx;
}
|