======================== RoutingSqlMapClient.java =========================
package com.localmatters.bo.core.util;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import com.ibatis.common.util.PaginatedList;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapSession;
import com.ibatis.sqlmap.client.event.RowHandler;
import com.ibatis.sqlmap.engine.execution.SqlExecutor;
import com.ibatis.sqlmap.engine.impl.ExtendedSqlMapClient;
import com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate;
import com.ibatis.sqlmap.engine.mapping.statement.MappedStatement;
import com.localmatters.bo.core.commons.VendorTypes;
public class RoutingSqlMapClient implements ExtendedSqlMapClient {
private Map<VendorTypes, ExtendedSqlMapClient> targetSqlMapClients;
public void flushDataCache() {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).flushDataCache();
}
public void flushDataCache(String cacheId) {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).flushDataCache(cacheId);
}
public SqlMapSession getSession() {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).getSession();
}
public SqlMapSession openSession() {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).openSession();
}
public SqlMapSession openSession(Connection conn) {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).openSession(conn);
}
public int delete(String id, Object parameterObject) throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).delete(id, parameterObject);
}
public int executeBatch() throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).executeBatch();
}
public Object insert(String id, Object parameterObject) throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).insert(id, parameterObject);
}
public List queryForList(String id, Object parameterObject)
throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryForList(id, parameterObject);
}
public List queryForList(String id, Object parameterObject, int skip,
int max) throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryForList(id, parameterObject, skip, max);
}
public Map queryForMap(String id, Object parameterObject, String keyProp)
throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryForMap(id, parameterObject, keyProp);
}
public Map queryForMap(String id, Object parameterObject, String keyProp,
String valueProp) throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryForMap(id, parameterObject, keyProp, valueProp);
}
public Object queryForObject(String id, Object parameterObject)
throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryForObject(id, parameterObject);
}
public Object queryForObject(String id, Object parameterObject,
Object resultObject) throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryForObject(id, parameterObject, resultObject);
}
public PaginatedList queryForPaginatedList(String id,
Object parameterObject, int pageSize) throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryForPaginatedList(id, parameterObject, pageSize);
}
public void queryWithRowHandler(String id, Object parameterObject,
RowHandler rowHandler) throws SQLException {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).queryWithRowHandler(id, parameterObject, rowHandler);
}
public void startBatch() throws SQLException {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).startBatch();
}
public int update(String id, Object parameterObject) throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).update(id, parameterObject);
}
public void commitTransaction() throws SQLException {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).commitTransaction();
}
public void endTransaction() throws SQLException {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).endTransaction();
}
public Connection getCurrentConnection() throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).getCurrentConnection();
}
public DataSource getDataSource() {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).getDataSource();
}
public Connection getUserConnection() throws SQLException {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).getUserConnection();
}
public void setUserConnection(Connection connnection) throws SQLException {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).setUserConnection(connnection);
}
public void startTransaction() throws SQLException {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).startTransaction();
}
public void startTransaction(int transactionIsolation) throws SQLException {
targetSqlMapClients.get(VendorContextHolder.getVendorType()).startTransaction(transactionIsolation);
}
public Map<VendorTypes, ExtendedSqlMapClient> getTargetSqlMapClients() {
return targetSqlMapClients;
}
public void setTargetSqlMapClients(
Map<VendorTypes, ExtendedSqlMapClient> targetSqlMapClients) {
this.targetSqlMapClients = targetSqlMapClients;
}
public SqlMapExecutorDelegate getDelegate() {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).getDelegate();
}
public MappedStatement getMappedStatement(String id) {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).getMappedStatement(id);
}
public SqlExecutor getSqlExecutor() {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).getSqlExecutor();
}
public boolean isEnhancementEnabled() {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).isEnhancementEnabled();
}
public boolean isLazyLoadingEnabled() {
return targetSqlMapClients.get(VendorContextHolder.getVendorType()).isLazyLoadingEnabled();
}
}