mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
make Transaction interface extends Closeable
To avoid method name conflict, JtaTransaction#close was renamed to closeConnection()
This commit is contained in:
@@ -3,12 +3,13 @@ package com.avaje.ebean;
|
||||
import javax.persistence.OptimisticLockException;
|
||||
import javax.persistence.PersistenceException;
|
||||
import javax.persistence.RollbackException;
|
||||
import java.io.Closeable;
|
||||
import java.sql.Connection;
|
||||
|
||||
/**
|
||||
* The Transaction object. Typically representing a JDBC or JTA transaction.
|
||||
*/
|
||||
public interface Transaction {
|
||||
public interface Transaction extends Closeable {
|
||||
|
||||
/**
|
||||
* Read Committed transaction isolation. Same as
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.avaje.ebeaninternal.server.transaction;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
@@ -687,4 +688,15 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
public final TransactionManager getTransactionManger() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for end(), which enables this class to be used in try-with-resources.
|
||||
*/
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
end();
|
||||
} catch (PersistenceException ex) {
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class JtaTransaction extends JdbcTransaction {
|
||||
}
|
||||
notifyRollback(e);
|
||||
} finally {
|
||||
close();
|
||||
closeConnection();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new PersistenceException(ex);
|
||||
@@ -107,7 +107,7 @@ public class JtaTransaction extends JdbcTransaction {
|
||||
/**
|
||||
* Close the underlying connection.
|
||||
*/
|
||||
private void close() throws SQLException {
|
||||
private void closeConnection() throws SQLException {
|
||||
if (connection != null) {
|
||||
connection.close();
|
||||
connection = null;
|
||||
|
||||
Reference in New Issue
Block a user