Updated jdbc data query manager and service

This commit is contained in:
Sambo Chea 2022-07-05 23:54:43 +07:00
parent 295cfc3707
commit ead3d83c86
4 changed files with 82 additions and 70 deletions

View File

@ -2,6 +2,7 @@
- DataSource - DataSource
- Core Context for DSM - Core Context for DSM
- DataFactory + JDBC Core
# Contributors # Contributors

View File

@ -1,69 +0,0 @@
package com.cubetiqs.sql;
import com.cubetiqs.mapper.MapperProvider;
import com.cubetiqs.mapper.RowMapperProvider;
import java.util.List;
import java.util.Map;
public final class DataFactory {
public static IExecuteResult<List<Object>> queryForList(JdbcDataQuery manager, String sql) {
return manager.queryForList(sql);
}
public static IExecuteResult<List<Object>> queryForList(JdbcDataQuery manager, String sql, Object... args) {
return manager.queryForList(sql, args);
}
public static <R> IExecuteResult<List<R>> queryForList(JdbcDataQuery manager, String sql, RowMapperProvider<R> mapper) {
return manager.queryForList(sql, mapper);
}
public static <R> IExecuteResult<List<R>> queryForList(JdbcDataQuery manager, String sql, RowMapperProvider<R> mapper, Object... args) {
return manager.queryForList(sql, mapper, args);
}
public static IExecuteResult<Object> queryForObject(JdbcDataQuery manager, String sql) {
return manager.queryForObject(sql);
}
public static IExecuteResult<Object> queryForObject(JdbcDataQuery manager, String sql, Object... args) {
return manager.queryForObject(sql, args);
}
public static <R> IExecuteResult<R> query(JdbcDataQuery manager, MapperProvider<Map<String, Object>, R> mapper, String sql, Class<R> clazz) {
return manager.query(mapper, sql, clazz);
}
public static <R> IExecuteResult<R> query(JdbcDataQuery manager, MapperProvider<Map<String, Object>, R> mapper, String sql, Class<R> clazz, Object... args) {
return manager.query(mapper, sql, clazz, args);
}
public static <R> IExecuteResult<R> query(JdbcDataQuery manager, String sql, RowMapperProvider<R> mapper) {
return manager.query(sql, mapper);
}
public static <R> IExecuteResult<R> query(JdbcDataQuery manager, String sql, RowMapperProvider<R> mapper, Object... args) {
return manager.query(sql, mapper, args);
}
public static IExecuteResult<List<Object>> queryForList(JdbcDataQuery manager, ISqlMapParameter parameter) {
return manager.queryForList(parameter);
}
public static <R> IExecuteResult<List<R>> queryForList(JdbcDataQuery manager, ISqlMapParameter parameter, RowMapperProvider<R> mapper) {
return manager.queryForList(parameter, mapper);
}
public static IExecuteResult<Object> queryForObject(JdbcDataQuery manager, ISqlMapParameter parameter) {
return manager.queryForObject(parameter);
}
public static <R> IExecuteResult<R> query(JdbcDataQuery manager, MapperProvider<Map<String, Object>, R> mapper, ISqlMapParameter parameter, Class<R> clazz) {
return manager.query(mapper, parameter, clazz);
}
public static <R> IExecuteResult<R> query(JdbcDataQuery manager, ISqlMapParameter parameter, RowMapperProvider<R> mapper) {
return manager.query(parameter, mapper);
}
}

View File

@ -1,7 +1,8 @@
package com.cubetiqs.sql; package com.cubetiqs.sql;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException;
public interface IDataManager { public interface IDataManager {
Connection getConnection(); Connection getConnection() throws SQLException;
} }

View File

@ -0,0 +1,79 @@
package com.cubetiqs.sql;
import com.cubetiqs.mapper.MapperProvider;
import com.cubetiqs.mapper.RowMapperProvider;
import java.util.List;
import java.util.Map;
public final class JdbcDataFactory {
private final JdbcDataQuery queryManager;
public JdbcDataFactory(JdbcDataQuery queryManager) {
this.queryManager = queryManager;
}
public static JdbcDataFactory create(JdbcDataQuery queryManager) {
return new JdbcDataFactory(queryManager);
}
public IExecuteResult<List<Object>> queryForList(String sql) {
return queryManager.queryForList(sql);
}
public IExecuteResult<List<Object>> queryForList(String sql, Object... args) {
return queryManager.queryForList(sql, args);
}
public <R> IExecuteResult<List<R>> queryForList(String sql, RowMapperProvider<R> mapper) {
return queryManager.queryForList(sql, mapper);
}
public <R> IExecuteResult<List<R>> queryForList(String sql, RowMapperProvider<R> mapper, Object... args) {
return queryManager.queryForList(sql, mapper, args);
}
public IExecuteResult<Object> queryForObject(String sql) {
return queryManager.queryForObject(sql);
}
public IExecuteResult<Object> queryForObject(String sql, Object... args) {
return queryManager.queryForObject(sql, args);
}
public <R> IExecuteResult<R> query(MapperProvider<Map<String, Object>, R> mapper, String sql, Class<R> clazz) {
return queryManager.query(mapper, sql, clazz);
}
public <R> IExecuteResult<R> query(MapperProvider<Map<String, Object>, R> mapper, String sql, Class<R> clazz, Object... args) {
return queryManager.query(mapper, sql, clazz, args);
}
public <R> IExecuteResult<R> query(String sql, RowMapperProvider<R> mapper) {
return queryManager.query(sql, mapper);
}
public <R> IExecuteResult<R> query(String sql, RowMapperProvider<R> mapper, Object... args) {
return queryManager.query(sql, mapper, args);
}
public IExecuteResult<List<Object>> queryForList(ISqlMapParameter parameter) {
return queryManager.queryForList(parameter);
}
public <R> IExecuteResult<List<R>> queryForList(ISqlMapParameter parameter, RowMapperProvider<R> mapper) {
return queryManager.queryForList(parameter, mapper);
}
public IExecuteResult<Object> queryForObject(ISqlMapParameter parameter) {
return queryManager.queryForObject(parameter);
}
public <R> IExecuteResult<R> query(MapperProvider<Map<String, Object>, R> mapper, ISqlMapParameter parameter, Class<R> clazz) {
return queryManager.query(mapper, parameter, clazz);
}
public <R> IExecuteResult<R> query(ISqlMapParameter parameter, RowMapperProvider<R> mapper) {
return queryManager.query(parameter, mapper);
}
}