mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
This commit is contained in:
@@ -114,6 +114,11 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
*/
|
||||
protected int depth;
|
||||
|
||||
/**
|
||||
* Set to true if the connection has autoCommit=true initially.
|
||||
*/
|
||||
protected final boolean autoCommit;
|
||||
|
||||
protected IdentityHashMap<Object,Object> persistingBeans;
|
||||
|
||||
protected HashSet<Integer> deletingBeansHash;
|
||||
@@ -137,6 +142,10 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
this.connection = connection;
|
||||
this.onQueryOnly = manager == null ? OnQueryOnly.ROLLBACK : manager.getOnQueryOnly();
|
||||
this.persistenceContext = new DefaultPersistenceContext();
|
||||
this.autoCommit = connection.getAutoCommit();
|
||||
if (this.autoCommit) {
|
||||
connection.setAutoCommit(false);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new PersistenceException(e);
|
||||
@@ -210,11 +219,7 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
* Return true if this is a bean that has already been saved/deleted.
|
||||
*/
|
||||
public boolean isRegisteredDeleteBean(Integer persistingBean) {
|
||||
if (deletingBeansHash == null) {
|
||||
return false;
|
||||
} else {
|
||||
return deletingBeansHash.contains(persistingBean);
|
||||
}
|
||||
return deletingBeansHash != null && deletingBeansHash.contains(persistingBean);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -439,13 +444,6 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether transaction logging is on for this transaction.
|
||||
*/
|
||||
public void setLoggingOn(boolean loggingOn) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this was an explicitly created transaction.
|
||||
*/
|
||||
@@ -503,6 +501,14 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
} catch (SQLException e) {
|
||||
logger.error("Error setting to readOnly?", e);
|
||||
}
|
||||
try {
|
||||
if (autoCommit) {
|
||||
// reset the autoCommit status prior to returning to pool
|
||||
connection.setAutoCommit(true);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
logger.error("Error setting to readOnly?", e);
|
||||
}
|
||||
try {
|
||||
connection.close();
|
||||
} catch (Exception ex) {
|
||||
@@ -702,10 +708,6 @@ public class JdbcTransaction implements SpiTransaction {
|
||||
return userObjects.get(name);
|
||||
}
|
||||
|
||||
public final TransactionManager getTransactionManger() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for end(), which enables this class to be used in try-with-resources.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user