No auto-commit for tx connections.
This commit is contained in:
@@ -41,19 +41,7 @@ public class DataSourceConnectionProvider implements ConnectionProvider
|
|||||||
public Connection getConnection (String ident, boolean readOnly)
|
public Connection getConnection (String ident, boolean readOnly)
|
||||||
throws PersistenceException
|
throws PersistenceException
|
||||||
{
|
{
|
||||||
try {
|
return getConnection(ident, readOnly, null);
|
||||||
Connection conn;
|
|
||||||
if (readOnly) {
|
|
||||||
conn = _readSource.getConnection();
|
|
||||||
conn.setReadOnly(true);
|
|
||||||
} else {
|
|
||||||
conn = _writeSource.getConnection();
|
|
||||||
}
|
|
||||||
return conn;
|
|
||||||
|
|
||||||
} catch (SQLException sqe) {
|
|
||||||
throw new PersistenceException(sqe);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// from ConnectionProvider
|
// from ConnectionProvider
|
||||||
@@ -83,7 +71,7 @@ public class DataSourceConnectionProvider implements ConnectionProvider
|
|||||||
public Connection getTxConnection (String ident) throws PersistenceException
|
public Connection getTxConnection (String ident) throws PersistenceException
|
||||||
{
|
{
|
||||||
// our connections are pooled, so we can just get them normally
|
// our connections are pooled, so we can just get them normally
|
||||||
return getConnection(ident, false);
|
return getConnection(ident, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// from ConnectionProvider
|
// from ConnectionProvider
|
||||||
@@ -112,6 +100,25 @@ public class DataSourceConnectionProvider implements ConnectionProvider
|
|||||||
// nothing doing, the caller has to shutdown the datasources
|
// nothing doing, the caller has to shutdown the datasources
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Connection getConnection (String ident, boolean readOnly, Boolean autoCommit)
|
||||||
|
throws PersistenceException
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Connection conn;
|
||||||
|
if (readOnly) {
|
||||||
|
conn = _readSource.getConnection();
|
||||||
|
conn.setReadOnly(true);
|
||||||
|
} else {
|
||||||
|
conn = _writeSource.getConnection();
|
||||||
|
}
|
||||||
|
if (autoCommit != null) conn.setAutoCommit(autoCommit);
|
||||||
|
return conn;
|
||||||
|
|
||||||
|
} catch (SQLException sqe) {
|
||||||
|
throw new PersistenceException(sqe);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected String _url;
|
protected String _url;
|
||||||
protected DataSource _readSource, _writeSource;
|
protected DataSource _readSource, _writeSource;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public class StaticConnectionProvider implements ConnectionProvider
|
|||||||
// from ConnectionProvider
|
// from ConnectionProvider
|
||||||
public Connection getTxConnection (String ident) throws PersistenceException
|
public Connection getTxConnection (String ident) throws PersistenceException
|
||||||
{
|
{
|
||||||
return getMapping(ident, false).openConnection(ident, null);
|
return getMapping(ident, false).openConnection(ident, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// from ConnectionProvider
|
// from ConnectionProvider
|
||||||
|
|||||||
Reference in New Issue
Block a user