Skip to content

Commit

Permalink
add: 支持配置psql是否支持supportSavePoint
Browse files Browse the repository at this point in the history
wendal committed Mar 29, 2019
1 parent a9cd08b commit 0fb1db0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/org/nutz/dao/impl/sql/run/NutDaoRunner.java
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
import org.nutz.dao.DatabaseMeta;
import org.nutz.dao.impl.DaoRunner;
import org.nutz.dao.sql.DaoStatement;
import org.nutz.lang.Configurable;
import org.nutz.lang.util.NutMap;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.trans.Atom;
@@ -23,12 +25,14 @@
* @author wendal
*
*/
public class NutDaoRunner implements DaoRunner {
public class NutDaoRunner implements DaoRunner, Configurable {

private static final Log log = Logs.get();

protected DataSource slaveDataSource;

protected boolean supportSavePoint = true;

public void run(final DataSource dataSource, final ConnCallback callback) {
if (callback instanceof DaoInterceptorChain) {
DaoInterceptorChain chain = (DaoInterceptorChain)callback;
@@ -99,7 +103,7 @@ protected void _runWithTransaction(Transaction t, DataSource dataSource, ConnCal
Savepoint sp = null;
try {
conn = t.getConnection(selectDataSource(t, dataSource, callback));
if (meta != null && meta.isPostgresql()) {
if (supportSavePoint && meta != null && meta.isPostgresql()) {
sp = conn.setSavepoint();
}
runCallback(conn, callback);
@@ -181,4 +185,9 @@ protected DataSource selectDataSource(Transaction t, DataSource master, ConnCall
}
return master;
}

@Override
public void setupProperties(NutMap conf) {
supportSavePoint = conf.getBoolean("nutz.dao.jdbc.psql.supportSavePoint", true);
}
}

0 comments on commit 0fb1db0

Please sign in to comment.