ソースを参照

优化sql执行器。

zhouhao 8 年 前
コミット
a78a9436cb

+ 25 - 0
hsweb-web-datasource/src/main/java/org/hsweb/web/datasource/dynamic/DynamicDataSourceSqlExecutorService.java

@@ -99,6 +99,31 @@ public class DynamicDataSourceSqlExecutorService extends AbstractJdbcSqlExecutor
         return data;
     }
 
+    @Transactional
+    public int update(String sql, Map<String, Object> param) throws SQLException {
+        return super.update(new SimpleSQL(sql, param));
+    }
+
+    @Transactional
+    public int update(String sql) throws SQLException {
+        return super.update(new SimpleSQL(sql));
+    }
+
+    @Transactional
+    public int delete(String sql, Map<String, Object> param) throws SQLException {
+        return super.delete(new SimpleSQL(sql, param));
+    }
+
+    @Transactional
+    public int delete(String sql) throws SQLException {
+        return super.delete(new SimpleSQL(sql));
+    }
+
+    @Transactional(propagation = Propagation.NOT_SUPPORTED)
+    public void exec(String sql) throws SQLException {
+        super.exec(new SimpleSQL(sql));
+    }
+
     @Override
     @Transactional(propagation = Propagation.NOT_SUPPORTED)
     public void exec(SQL sql) throws SQLException {

+ 33 - 0
hsweb-web-service/hsweb-web-service-simple/src/main/java/org/hsweb/web/service/impl/basic/SqlExecutorService.java

@@ -8,6 +8,7 @@ import org.hsweb.ezorm.render.support.simple.SimpleSQL;
 import org.hsweb.web.core.authorize.ExpressionScopeBean;
 import org.springframework.jdbc.datasource.DataSourceUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
@@ -34,6 +35,7 @@ public class SqlExecutorService extends AbstractJdbcSqlExecutor implements Expre
         DataSourceUtils.releaseConnection(connection, dataSource);
     }
 
+
     @Override
     @Transactional(readOnly = true)
     public <T> List<T> list(SQL sql, ObjectWrapper<T> wrapper) throws SQLException {
@@ -82,6 +84,37 @@ public class SqlExecutorService extends AbstractJdbcSqlExecutor implements Expre
         return data;
     }
 
+    @Transactional
+    public int update(String sql, Map<String, Object> param) throws SQLException {
+        return super.update(new SimpleSQL(sql, param));
+    }
+
+    @Transactional
+    public int update(String sql) throws SQLException {
+        return super.update(new SimpleSQL(sql));
+    }
+
+    @Transactional
+    public int delete(String sql, Map<String, Object> param) throws SQLException {
+        return super.delete(new SimpleSQL(sql, param));
+    }
+
+    @Transactional
+    public int delete(String sql) throws SQLException {
+        return super.delete(new SimpleSQL(sql));
+    }
+
+    @Transactional(propagation = Propagation.NOT_SUPPORTED)
+    public void exec(String sql) throws SQLException {
+        super.exec(new SimpleSQL(sql));
+    }
+
+    @Override
+    @Transactional(propagation = Propagation.NOT_SUPPORTED)
+    public void exec(SQL sql) throws SQLException {
+        super.exec(sql);
+    }
+
     public SQL create(String sql) {
         return new SimpleSQL(sql);
     }