保留覆盖的源码
This commit is contained in:
@@ -123,6 +123,18 @@
|
|||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zt.plat</groupId>
|
||||||
|
<artifactId>zt-module-qms-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zt.plat</groupId>
|
||||||
|
<artifactId>zt-module-product-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -11,9 +11,12 @@ import com.alibaba.druid.support.logging.Log;
|
|||||||
import com.alibaba.druid.support.logging.LogFactory;
|
import com.alibaba.druid.support.logging.LogFactory;
|
||||||
import com.alibaba.druid.util.JdbcUtils;
|
import com.alibaba.druid.util.JdbcUtils;
|
||||||
import com.alibaba.druid.util.MySqlUtils;
|
import com.alibaba.druid.util.MySqlUtils;
|
||||||
|
|
||||||
import java.net.SocketTimeoutException;
|
import java.net.SocketTimeoutException;
|
||||||
import java.sql.*;
|
import java.sql.Connection;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.SQLWarning;
|
||||||
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package com.zt.plat.module.bpm.framework.rpc.config;
|
package com.zt.plat.module.bpm.framework.rpc.config;
|
||||||
|
|
||||||
|
import com.zt.plat.module.capital.api.splyAmountRequest.AmountRequestApi;
|
||||||
import com.zt.plat.module.capital.api.splyAmtCrdtAppl.AmountCreditApplyApi;
|
import com.zt.plat.module.capital.api.splyAmtCrdtAppl.AmountCreditApplyApi;
|
||||||
|
import com.zt.plat.module.product.api.MesProcessRoutApi;
|
||||||
|
import com.zt.plat.module.product.api.plan.MesCompanyPlanApi;
|
||||||
|
import com.zt.plat.module.product.api.plan.MesFactoryPlanApi;
|
||||||
|
import com.zt.plat.module.qms.api.task.QmsApi;
|
||||||
import com.zt.plat.module.system.api.dept.DeptApi;
|
import com.zt.plat.module.system.api.dept.DeptApi;
|
||||||
import com.zt.plat.module.system.api.dept.PostApi;
|
import com.zt.plat.module.system.api.dept.PostApi;
|
||||||
import com.zt.plat.module.system.api.dict.DictDataApi;
|
import com.zt.plat.module.system.api.dict.DictDataApi;
|
||||||
@@ -13,6 +18,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
|
|
||||||
@Configuration(value = "bpmRpcConfiguration", proxyBeanMethods = false)
|
@Configuration(value = "bpmRpcConfiguration", proxyBeanMethods = false)
|
||||||
@EnableFeignClients(clients = {RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class,
|
@EnableFeignClients(clients = {RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class,
|
||||||
PermissionApi.class, AmountCreditApplyApi.class})
|
PermissionApi.class, AmountCreditApplyApi.class, MesCompanyPlanApi.class, MesFactoryPlanApi.class, MesProcessRoutApi.class,
|
||||||
|
QmsApi.class, AmountRequestApi.class})
|
||||||
public class RpcConfiguration {
|
public class RpcConfiguration {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import liquibase.statement.DatabaseFunction;
|
|||||||
import liquibase.util.StringUtil;
|
import liquibase.util.StringUtil;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
@DataTypeInfo(name = "boolean", aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT)
|
@DataTypeInfo(name = "boolean", aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"}, minParameters = 0, maxParameters = 0, priority = LiquibaseDataType.PRIORITY_DEFAULT)
|
||||||
public class BooleanType extends LiquibaseDataType {
|
public class BooleanType extends LiquibaseDataType {
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package liquibase.datatype.core;
|
||||||
|
|
||||||
|
import liquibase.database.Database;
|
||||||
|
import liquibase.database.core.DmDatabase;
|
||||||
|
import liquibase.datatype.DataTypeInfo;
|
||||||
|
import liquibase.datatype.DatabaseDataType;
|
||||||
|
|
||||||
|
@DataTypeInfo(
|
||||||
|
name = "boolean",
|
||||||
|
aliases = {"java.sql.Types.BOOLEAN", "java.lang.Boolean", "bit", "bool"},
|
||||||
|
minParameters = 0,
|
||||||
|
maxParameters = 0,
|
||||||
|
priority = 2
|
||||||
|
)
|
||||||
|
public class DmBooleanType extends BooleanType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Database database) {
|
||||||
|
if (database instanceof DmDatabase) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return super.supports(database);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DatabaseDataType toDatabaseDataType(Database database) {
|
||||||
|
if (database instanceof DmDatabase) {
|
||||||
|
return new DatabaseDataType("NUMBER", 1);
|
||||||
|
}
|
||||||
|
return super.toDatabaseDataType(database);
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -12,8 +12,29 @@
|
|||||||
*/
|
*/
|
||||||
package org.flowable.common.engine.impl;
|
package org.flowable.common.engine.impl;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import java.io.InputStream;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DatabaseMetaData;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Properties;
|
||||||
|
import java.util.ServiceLoader;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.naming.InitialContext;
|
||||||
|
import javax.sql.DataSource;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
|
import org.apache.ibatis.builder.xml.XMLConfigBuilder;
|
||||||
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
|
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
|
||||||
@@ -26,7 +47,27 @@ import org.apache.ibatis.session.defaults.DefaultSqlSessionFactory;
|
|||||||
import org.apache.ibatis.transaction.TransactionFactory;
|
import org.apache.ibatis.transaction.TransactionFactory;
|
||||||
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
|
import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory;
|
||||||
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
|
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
|
||||||
import org.apache.ibatis.type.*;
|
import org.apache.ibatis.type.ArrayTypeHandler;
|
||||||
|
import org.apache.ibatis.type.BigDecimalTypeHandler;
|
||||||
|
import org.apache.ibatis.type.BlobInputStreamTypeHandler;
|
||||||
|
import org.apache.ibatis.type.BlobTypeHandler;
|
||||||
|
import org.apache.ibatis.type.BooleanTypeHandler;
|
||||||
|
import org.apache.ibatis.type.ByteTypeHandler;
|
||||||
|
import org.apache.ibatis.type.ClobTypeHandler;
|
||||||
|
import org.apache.ibatis.type.DateOnlyTypeHandler;
|
||||||
|
import org.apache.ibatis.type.DateTypeHandler;
|
||||||
|
import org.apache.ibatis.type.DoubleTypeHandler;
|
||||||
|
import org.apache.ibatis.type.FloatTypeHandler;
|
||||||
|
import org.apache.ibatis.type.IntegerTypeHandler;
|
||||||
|
import org.apache.ibatis.type.JdbcType;
|
||||||
|
import org.apache.ibatis.type.LongTypeHandler;
|
||||||
|
import org.apache.ibatis.type.NClobTypeHandler;
|
||||||
|
import org.apache.ibatis.type.NStringTypeHandler;
|
||||||
|
import org.apache.ibatis.type.ShortTypeHandler;
|
||||||
|
import org.apache.ibatis.type.SqlxmlTypeHandler;
|
||||||
|
import org.apache.ibatis.type.StringTypeHandler;
|
||||||
|
import org.apache.ibatis.type.TimeOnlyTypeHandler;
|
||||||
|
import org.apache.ibatis.type.TypeHandlerRegistry;
|
||||||
import org.flowable.common.engine.api.FlowableException;
|
import org.flowable.common.engine.api.FlowableException;
|
||||||
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
|
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
|
||||||
import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher;
|
import org.flowable.common.engine.api.delegate.event.FlowableEventDispatcher;
|
||||||
@@ -38,10 +79,25 @@ import org.flowable.common.engine.impl.cfg.CommandExecutorImpl;
|
|||||||
import org.flowable.common.engine.impl.cfg.IdGenerator;
|
import org.flowable.common.engine.impl.cfg.IdGenerator;
|
||||||
import org.flowable.common.engine.impl.cfg.TransactionContextFactory;
|
import org.flowable.common.engine.impl.cfg.TransactionContextFactory;
|
||||||
import org.flowable.common.engine.impl.cfg.standalone.StandaloneMybatisTransactionContextFactory;
|
import org.flowable.common.engine.impl.cfg.standalone.StandaloneMybatisTransactionContextFactory;
|
||||||
import org.flowable.common.engine.impl.db.*;
|
import org.flowable.common.engine.impl.db.CommonDbSchemaManager;
|
||||||
|
import org.flowable.common.engine.impl.db.DbSqlSessionFactory;
|
||||||
|
import org.flowable.common.engine.impl.db.LogSqlExecutionTimePlugin;
|
||||||
|
import org.flowable.common.engine.impl.db.MybatisTypeAliasConfigurator;
|
||||||
|
import org.flowable.common.engine.impl.db.MybatisTypeHandlerConfigurator;
|
||||||
|
import org.flowable.common.engine.impl.db.SchemaManager;
|
||||||
import org.flowable.common.engine.impl.event.EventDispatchAction;
|
import org.flowable.common.engine.impl.event.EventDispatchAction;
|
||||||
import org.flowable.common.engine.impl.event.FlowableEventDispatcherImpl;
|
import org.flowable.common.engine.impl.event.FlowableEventDispatcherImpl;
|
||||||
import org.flowable.common.engine.impl.interceptor.*;
|
import org.flowable.common.engine.impl.interceptor.Command;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandConfig;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandContextFactory;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandContextInterceptor;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandExecutor;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandInterceptor;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CrDbRetryInterceptor;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.DefaultCommandInvoker;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.LogInterceptor;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.SessionFactory;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.TransactionContextInterceptor;
|
||||||
import org.flowable.common.engine.impl.lock.LockManager;
|
import org.flowable.common.engine.impl.lock.LockManager;
|
||||||
import org.flowable.common.engine.impl.lock.LockManagerImpl;
|
import org.flowable.common.engine.impl.lock.LockManagerImpl;
|
||||||
import org.flowable.common.engine.impl.logging.LoggingListener;
|
import org.flowable.common.engine.impl.logging.LoggingListener;
|
||||||
@@ -51,7 +107,13 @@ import org.flowable.common.engine.impl.persistence.GenericManagerFactory;
|
|||||||
import org.flowable.common.engine.impl.persistence.StrongUuidGenerator;
|
import org.flowable.common.engine.impl.persistence.StrongUuidGenerator;
|
||||||
import org.flowable.common.engine.impl.persistence.cache.EntityCache;
|
import org.flowable.common.engine.impl.persistence.cache.EntityCache;
|
||||||
import org.flowable.common.engine.impl.persistence.cache.EntityCacheImpl;
|
import org.flowable.common.engine.impl.persistence.cache.EntityCacheImpl;
|
||||||
import org.flowable.common.engine.impl.persistence.entity.*;
|
import org.flowable.common.engine.impl.persistence.entity.ByteArrayEntityManager;
|
||||||
|
import org.flowable.common.engine.impl.persistence.entity.ByteArrayEntityManagerImpl;
|
||||||
|
import org.flowable.common.engine.impl.persistence.entity.Entity;
|
||||||
|
import org.flowable.common.engine.impl.persistence.entity.PropertyEntityManager;
|
||||||
|
import org.flowable.common.engine.impl.persistence.entity.PropertyEntityManagerImpl;
|
||||||
|
import org.flowable.common.engine.impl.persistence.entity.TableDataManager;
|
||||||
|
import org.flowable.common.engine.impl.persistence.entity.TableDataManagerImpl;
|
||||||
import org.flowable.common.engine.impl.persistence.entity.data.ByteArrayDataManager;
|
import org.flowable.common.engine.impl.persistence.entity.data.ByteArrayDataManager;
|
||||||
import org.flowable.common.engine.impl.persistence.entity.data.PropertyDataManager;
|
import org.flowable.common.engine.impl.persistence.entity.data.PropertyDataManager;
|
||||||
import org.flowable.common.engine.impl.persistence.entity.data.impl.MybatisByteArrayDataManager;
|
import org.flowable.common.engine.impl.persistence.entity.data.impl.MybatisByteArrayDataManager;
|
||||||
@@ -65,14 +127,8 @@ import org.flowable.eventregistry.api.EventRegistryEventConsumer;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import javax.naming.InitialContext;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import javax.sql.DataSource;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.sql.*;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public abstract class AbstractEngineConfiguration {
|
public abstract class AbstractEngineConfiguration {
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,394 @@
|
|||||||
|
/* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.flowable.common.engine.impl.db;
|
||||||
|
|
||||||
|
import org.apache.ibatis.session.SqlSessionFactory;
|
||||||
|
import org.flowable.common.engine.api.FlowableException;
|
||||||
|
import org.flowable.common.engine.impl.context.Context;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.Session;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.SessionFactory;
|
||||||
|
import org.flowable.common.engine.impl.persistence.cache.EntityCache;
|
||||||
|
import org.flowable.common.engine.impl.persistence.entity.Entity;
|
||||||
|
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Tom Baeyens
|
||||||
|
* @author Joram Barrez
|
||||||
|
*/
|
||||||
|
public class DbSqlSessionFactory implements SessionFactory {
|
||||||
|
|
||||||
|
protected Map<String, Map<String, String>> databaseSpecificStatements = new HashMap<>();
|
||||||
|
|
||||||
|
protected String databaseType;
|
||||||
|
protected String databaseTablePrefix = "";
|
||||||
|
protected boolean tablePrefixIsSchema;
|
||||||
|
|
||||||
|
protected String databaseCatalog;
|
||||||
|
protected String databaseSchema;
|
||||||
|
protected SqlSessionFactory sqlSessionFactory;
|
||||||
|
protected Map<String, String> statementMappings;
|
||||||
|
|
||||||
|
protected Map<Class<?>, String> insertStatements = new ConcurrentHashMap<>();
|
||||||
|
protected Map<Class<?>, String> updateStatements = new ConcurrentHashMap<>();
|
||||||
|
protected Map<Class<?>, String> deleteStatements = new ConcurrentHashMap<>();
|
||||||
|
protected Map<Class<?>, String> selectStatements = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
protected List<Class<? extends Entity>> insertionOrder = new ArrayList<>();
|
||||||
|
protected List<Class<? extends Entity>> deletionOrder = new ArrayList<>();
|
||||||
|
|
||||||
|
protected boolean isDbHistoryUsed = true;
|
||||||
|
|
||||||
|
protected Set<Class<? extends Entity>> bulkInserteableEntityClasses = new HashSet<>();
|
||||||
|
protected Map<Class<?>, String> bulkInsertStatements = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
protected int maxNrOfStatementsInBulkInsert = 100;
|
||||||
|
|
||||||
|
protected Map<String, Class<?>> logicalNameToClassMapping = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
|
protected boolean usePrefixId;
|
||||||
|
|
||||||
|
public DbSqlSessionFactory(boolean usePrefixId) {
|
||||||
|
this.usePrefixId = usePrefixId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> getSessionType() {
|
||||||
|
return DbSqlSession.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Session openSession(CommandContext commandContext) {
|
||||||
|
DbSqlSession dbSqlSession = createDbSqlSession();
|
||||||
|
// 当前系统适配 dm,如果存在 schema 为空的情况,从 connection 获取
|
||||||
|
try {
|
||||||
|
if (getDatabaseSchema() == null || getDatabaseSchema().length() == 0){
|
||||||
|
String schemaFromUrl = extractSchemaFromJdbcUrl(dbSqlSession.getSqlSession().getConnection());
|
||||||
|
if (schemaFromUrl != null && schemaFromUrl.length() > 0) {
|
||||||
|
setDatabaseSchema(schemaFromUrl);
|
||||||
|
} else {
|
||||||
|
setDatabaseSchema(dbSqlSession.getSqlSession().getConnection().getSchema());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dbSqlSession.getSqlSession().getConnection().getSchema();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getDatabaseSchema() != null && getDatabaseSchema().length() > 0) {
|
||||||
|
try {
|
||||||
|
dbSqlSession.getSqlSession().getConnection().setSchema(getDatabaseSchema());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new FlowableException("Could not set database schema on connection", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getDatabaseCatalog() != null && getDatabaseCatalog().length() > 0) {
|
||||||
|
try {
|
||||||
|
dbSqlSession.getSqlSession().getConnection().setCatalog(getDatabaseCatalog());
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new FlowableException("Could not set database catalog on connection", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dbSqlSession.getSqlSession().getConnection() == null) {
|
||||||
|
throw new FlowableException("Invalid dbSqlSession: no active connection found");
|
||||||
|
}
|
||||||
|
return dbSqlSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected DbSqlSession createDbSqlSession() {
|
||||||
|
return new DbSqlSession(this, Context.getCommandContext().getSession(EntityCache.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert, update and delete statements
|
||||||
|
// /////////////////////////////////////
|
||||||
|
|
||||||
|
public String getInsertStatement(Entity object) {
|
||||||
|
return getStatement(object.getClass(), insertStatements, "insert");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getInsertStatement(Class<? extends Entity> clazz) {
|
||||||
|
return getStatement(clazz, insertStatements, "insert");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdateStatement(Entity object) {
|
||||||
|
return getStatement(object.getClass(), updateStatements, "update");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDeleteStatement(Class<?> entityClass) {
|
||||||
|
return getStatement(entityClass, deleteStatements, "delete");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSelectStatement(Class<?> entityClass) {
|
||||||
|
return getStatement(entityClass, selectStatements, "select");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String getStatement(Class<?> entityClass, Map<Class<?>, String> cachedStatements, String prefix) {
|
||||||
|
String statement = cachedStatements.get(entityClass);
|
||||||
|
if (statement != null) {
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
statement = prefix + entityClass.getSimpleName();
|
||||||
|
if (statement.endsWith("Impl")) {
|
||||||
|
statement = statement.substring(0, statement.length() - 10); // removing 'entityImpl'
|
||||||
|
} else {
|
||||||
|
statement = statement.substring(0, statement.length() - 6); // removing 'entity'
|
||||||
|
}
|
||||||
|
cachedStatements.put(entityClass, statement);
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
|
||||||
|
// db specific mappings
|
||||||
|
// /////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
protected void addDatabaseSpecificStatement(String databaseType, String activitiStatement, String ibatisStatement) {
|
||||||
|
Map<String, String> specificStatements = databaseSpecificStatements.get(databaseType);
|
||||||
|
if (specificStatements == null) {
|
||||||
|
specificStatements = new HashMap<>();
|
||||||
|
databaseSpecificStatements.put(databaseType, specificStatements);
|
||||||
|
}
|
||||||
|
specificStatements.put(activitiStatement, ibatisStatement);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String mapStatement(String statement) {
|
||||||
|
if (statementMappings == null) {
|
||||||
|
return statement;
|
||||||
|
}
|
||||||
|
String mappedStatement = statementMappings.get(statement);
|
||||||
|
return (mappedStatement != null ? mappedStatement : statement);
|
||||||
|
}
|
||||||
|
|
||||||
|
// customized getters and setters
|
||||||
|
// ///////////////////////////////////////////
|
||||||
|
|
||||||
|
public void setDatabaseType(String databaseType) {
|
||||||
|
this.databaseType = databaseType;
|
||||||
|
this.statementMappings = databaseSpecificStatements.get(databaseType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isMysql() {
|
||||||
|
return "mysql".equals(getDatabaseType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isOracle() {
|
||||||
|
return "oracle".equals(getDatabaseType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean isBulkInsertable(Class<? extends Entity> entityClass) {
|
||||||
|
return bulkInserteableEntityClasses != null && bulkInserteableEntityClasses.contains(entityClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
public String getBulkInsertStatement(Class clazz) {
|
||||||
|
return getStatement(clazz, bulkInsertStatements, "bulkInsert");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Class<? extends Entity>> getBulkInserteableEntityClasses() {
|
||||||
|
return bulkInserteableEntityClasses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBulkInserteableEntityClasses(Set<Class<? extends Entity>> bulkInserteableEntityClasses) {
|
||||||
|
this.bulkInserteableEntityClasses = bulkInserteableEntityClasses;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxNrOfStatementsInBulkInsert() {
|
||||||
|
return maxNrOfStatementsInBulkInsert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxNrOfStatementsInBulkInsert(int maxNrOfStatementsInBulkInsert) {
|
||||||
|
this.maxNrOfStatementsInBulkInsert = maxNrOfStatementsInBulkInsert;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Class<?>, String> getBulkInsertStatements() {
|
||||||
|
return bulkInsertStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBulkInsertStatements(Map<Class<?>, String> bulkInsertStatements) {
|
||||||
|
this.bulkInsertStatements = bulkInsertStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
// getters and setters //////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
public SqlSessionFactory getSqlSessionFactory() {
|
||||||
|
return sqlSessionFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
|
||||||
|
this.sqlSessionFactory = sqlSessionFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatabaseType() {
|
||||||
|
return databaseType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Map<String, String>> getDatabaseSpecificStatements() {
|
||||||
|
return databaseSpecificStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatabaseSpecificStatements(Map<String, Map<String, String>> databaseSpecificStatements) {
|
||||||
|
this.databaseSpecificStatements = databaseSpecificStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getStatementMappings() {
|
||||||
|
return statementMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatementMappings(Map<String, String> statementMappings) {
|
||||||
|
this.statementMappings = statementMappings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Class<?>, String> getInsertStatements() {
|
||||||
|
return insertStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsertStatements(Map<Class<?>, String> insertStatements) {
|
||||||
|
this.insertStatements = insertStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Class<?>, String> getUpdateStatements() {
|
||||||
|
return updateStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateStatements(Map<Class<?>, String> updateStatements) {
|
||||||
|
this.updateStatements = updateStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Class<?>, String> getDeleteStatements() {
|
||||||
|
return deleteStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleteStatements(Map<Class<?>, String> deleteStatements) {
|
||||||
|
this.deleteStatements = deleteStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Class<?>, String> getSelectStatements() {
|
||||||
|
return selectStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectStatements(Map<Class<?>, String> selectStatements) {
|
||||||
|
this.selectStatements = selectStatements;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDbHistoryUsed() {
|
||||||
|
return isDbHistoryUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDbHistoryUsed(boolean isDbHistoryUsed) {
|
||||||
|
this.isDbHistoryUsed = isDbHistoryUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatabaseTablePrefix(String databaseTablePrefix) {
|
||||||
|
this.databaseTablePrefix = databaseTablePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatabaseTablePrefix() {
|
||||||
|
return databaseTablePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatabaseCatalog() {
|
||||||
|
return databaseCatalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatabaseCatalog(String databaseCatalog) {
|
||||||
|
this.databaseCatalog = databaseCatalog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDatabaseSchema() {
|
||||||
|
return databaseSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDatabaseSchema(String databaseSchema) {
|
||||||
|
this.databaseSchema = databaseSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTablePrefixIsSchema(boolean tablePrefixIsSchema) {
|
||||||
|
this.tablePrefixIsSchema = tablePrefixIsSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTablePrefixIsSchema() {
|
||||||
|
return tablePrefixIsSchema;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Class<? extends Entity>> getInsertionOrder() {
|
||||||
|
return insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInsertionOrder(List<Class<? extends Entity>> insertionOrder) {
|
||||||
|
this.insertionOrder = insertionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Class<? extends Entity>> getDeletionOrder() {
|
||||||
|
return deletionOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeletionOrder(List<Class<? extends Entity>> deletionOrder) {
|
||||||
|
this.deletionOrder = deletionOrder;
|
||||||
|
}
|
||||||
|
public void addLogicalEntityClassMapping(String logicalName, Class<?> entityClass) {
|
||||||
|
logicalNameToClassMapping.put(logicalName, entityClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Class<?>> getLogicalNameToClassMapping() {
|
||||||
|
return logicalNameToClassMapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLogicalNameToClassMapping(Map<String, Class<?>> logicalNameToClassMapping) {
|
||||||
|
this.logicalNameToClassMapping = logicalNameToClassMapping;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUsePrefixId() {
|
||||||
|
return usePrefixId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsePrefixId(boolean usePrefixId) {
|
||||||
|
this.usePrefixId = usePrefixId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String extractSchemaFromJdbcUrl(java.sql.Connection connection) {
|
||||||
|
if (connection == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String url = connection.getMetaData().getURL();
|
||||||
|
if (url == null || url.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
int queryIndex = url.indexOf('?');
|
||||||
|
if (queryIndex < 0 || queryIndex == url.length() - 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String query = url.substring(queryIndex + 1);
|
||||||
|
String[] parts = query.split("[&;]");
|
||||||
|
for (String part : parts) {
|
||||||
|
int eqIndex = part.indexOf('=');
|
||||||
|
if (eqIndex <= 0 || eqIndex == part.length() - 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String key = part.substring(0, eqIndex).trim().toLowerCase(Locale.ROOT);
|
||||||
|
if ("schema".equals(key) || "currentschema".equals(key) || "current_schema".equals(key)) {
|
||||||
|
String value = part.substring(eqIndex + 1).trim();
|
||||||
|
if ((value.startsWith("\"") && value.endsWith("\"")) || (value.startsWith("'") && value.endsWith("'"))) {
|
||||||
|
value = value.substring(1, value.length() - 1);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (SQLException ignored) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user