本文整理了Java中org.apache.ibatis.session.Configuration.hasStatement()
方法的一些代码示例,展示了Configuration.hasStatement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.hasStatement()
方法的具体详情如下:
包路径:org.apache.ibatis.session.Configuration
类名称:Configuration
方法名:hasStatement
暂无
代码示例来源:origin: baomidou/mybatis-plus
/**
* 是否已经存在MappedStatement
*
* @param mappedStatement
* @return
*/
private boolean hasMappedStatement(String mappedStatement) {
return configuration.hasStatement(mappedStatement, false);
}
代码示例来源:origin: baomidou/mybatis-plus
/**
* 是否已经存在MappedStatement
*
* @param mappedStatement MappedStatement
* @return true or false
*/
private boolean hasMappedStatement(String mappedStatement) {
return configuration.hasStatement(mappedStatement, false);
}
代码示例来源:origin: baomidou/mybatis-plus
private MappedStatement resolveMappedStatement(Class<?> mapperInterface, String methodName,
Class<?> declaringClass, Configuration configuration) {
String statementId = mapperInterface.getName() + "." + methodName;
if (configuration.hasStatement(statementId)) {
return configuration.getMappedStatement(statementId);
} else if (mapperInterface.equals(declaringClass)) {
return null;
}
for (Class<?> superInterface : mapperInterface.getInterfaces()) {
if (declaringClass.isAssignableFrom(superInterface)) {
MappedStatement ms = resolveMappedStatement(superInterface, methodName,
declaringClass, configuration);
if (ms != null) {
return ms;
}
}
}
return null;
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
public boolean hasStatement(String statementName) {
return hasStatement(statementName, true);
}
代码示例来源:origin: org.mybatis/mybatis
public boolean hasStatement(String statementName) {
return hasStatement(statementName, true);
}
代码示例来源:origin: camunda/camunda-bpm-platform
private MappedStatement resolveMappedStatement(Class<?> mapperInterface, String methodName,
Class<?> declaringClass, Configuration configuration) {
String statementId = mapperInterface.getName() + "." + methodName;
if (configuration.hasStatement(statementId)) {
return configuration.getMappedStatement(statementId);
} else if (mapperInterface.equals(declaringClass)) {
return null;
}
for (Class<?> superInterface : mapperInterface.getInterfaces()) {
if (declaringClass.isAssignableFrom(superInterface)) {
MappedStatement ms = resolveMappedStatement(superInterface, methodName,
declaringClass, configuration);
if (ms != null) {
return ms;
}
}
}
return null;
}
}
代码示例来源:origin: org.mybatis/mybatis
private MappedStatement resolveMappedStatement(Class<?> mapperInterface, String methodName,
Class<?> declaringClass, Configuration configuration) {
String statementId = mapperInterface.getName() + "." + methodName;
if (configuration.hasStatement(statementId)) {
return configuration.getMappedStatement(statementId);
} else if (mapperInterface.equals(declaringClass)) {
return null;
}
for (Class<?> superInterface : mapperInterface.getInterfaces()) {
if (declaringClass.isAssignableFrom(superInterface)) {
MappedStatement ms = resolveMappedStatement(superInterface, methodName,
declaringClass, configuration);
if (ms != null) {
return ms;
}
}
}
return null;
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
private boolean databaseIdMatchesCurrent(String id, String databaseId, String requiredDatabaseId) {
if (requiredDatabaseId != null) {
if (!requiredDatabaseId.equals(databaseId)) {
return false;
}
} else {
if (databaseId != null) {
return false;
}
// skip this statement if there is a previous one with a not null databaseId
id = builderAssistant.applyCurrentNamespace(id, false);
if (this.configuration.hasStatement(id, false)) {
MappedStatement previous = this.configuration.getMappedStatement(id, false); // issue #2
if (previous.getDatabaseId() != null) {
return false;
}
}
}
return true;
}
代码示例来源:origin: org.mybatis/mybatis
private boolean databaseIdMatchesCurrent(String id, String databaseId, String requiredDatabaseId) {
if (requiredDatabaseId != null) {
if (!requiredDatabaseId.equals(databaseId)) {
return false;
}
} else {
if (databaseId != null) {
return false;
}
// skip this statement if there is a previous one with a not null databaseId
id = builderAssistant.applyCurrentNamespace(id, false);
if (this.configuration.hasStatement(id, false)) {
MappedStatement previous = this.configuration.getMappedStatement(id, false); // issue #2
if (previous.getDatabaseId() != null) {
return false;
}
}
}
return true;
}
代码示例来源:origin: com.github.drtrang/spring-boot-autoconfigure
/**
* 是否已经存在该 msId
*/
private boolean hasMappedStatement(String msId) {
return configuration.hasStatement(msId, false);
}
代码示例来源:origin: net.oschina.zcx7878/cicada.boot-mybatis
/**
* 是否已经存在该ID
*
* @param msId
* @return
*/
private boolean hasMappedStatement(String msId)
{
return configuration.hasStatement(msId, false);
}
代码示例来源:origin: io.github.yangziwen/quick-dao-mybatis
private boolean hasMappedStatement(String id) {
return configuration.hasStatement(id, false);
}
代码示例来源:origin: chanedi/QuickProject
public boolean hasStatement(String statementName, boolean validateIncompleteStatements) {
super.hasStatement(statementName, validateIncompleteStatements);
return mappedStatements.containsKey(statementName);
}
代码示例来源:origin: com.talanlabs/bean-mybatis
@Override
public boolean hasStatement(String statementName, boolean validateIncompleteStatements) {
boolean res = super.hasStatement(statementName, validateIncompleteStatements);
if (!res) {
res = verifyAndCreateMappedStatement(statementName);
}
return res;
}
代码示例来源:origin: com.talanlabs/component-mybatis
@Override
public boolean hasStatement(String statementName, boolean validateIncompleteStatements) {
boolean res = super.hasStatement(statementName, validateIncompleteStatements);
if (!res) {
res = verifyAndCreateMappedStatement(statementName);
}
return res;
}
代码示例来源:origin: com.gitee.hengboy/mybatis-enhance-core
/**
* 处理MapperClass内的匹配NamedMethod的MappedStatement以及SqlSource
*
* @param configuration MyBatis配置对象
* @param mapperClass Mapper的类型
*/
public void namedSupport(Configuration configuration, Class<?> mapperClass) {
if (ObjectUtils.isEmpty(mapperClass)) {
throw new EnhanceFrameworkException("处理NamedMethod MappedStatement时,参数[mapperClass]为必填项.");
}
// 获取Mapper内定义的方法不包含上级接口
Method[] methods = mapperClass.getDeclaredMethods();
// 遍历Mapper内定义的每一个方法
for (Method method : methods) {
// MappedStatement Id
String statementId = mapperClass.getName() + "." + method.getName();
// 如果匹配方法规则查询
// 执行创建MappedStatement对象
// 调用对应的Provider,执行重载SqlSource
if (!configuration.hasStatement(statementId) && NamedMethodHelper.isMatchNamed(method.getName())) {
logger.debug("Invoke Named Reload : {} SqlSource.", statementId);
MappedStatement statement = new MappedStatement.Builder(configuration, statementId, new DynamicSqlSource(configuration, new TextSqlNode("this is empty.")), getSqlCommandType(method.getName())).build();
// 将MappedStatement添加到Configuration
configuration.addMappedStatement(statement);
// 会自动根据方法规则匹配对应的Provider
BaseProvider provider = ProviderHelper.getMethodProvider(statementId);
provider.invokeNamedProviderMethod(statement);
}
}
}
代码示例来源:origin: com.intoverflow.booster/booster-core
public void buildMethod(Method method) {
this.method = method;// 方法名
String mappedStatementId = getMappedStatementId();
if (assistant.getConfiguration().hasStatement(mappedStatementId)) {
log.warn("Mybatis MappedStatement exists: {}", mappedStatementId);
this.duplicated = true;
return;
}
// Lang
buildLanguageDriver(method);
// 参数类型
// buildParameterType(method);
// 返回值类型
buildReturnType(method);
// 主键策略
setKeyGenerator(NoKeyGenerator.INSTANCE);
setKeyProperty(null);
setKeyColumn(null);
buildResultMapId(method);
}
代码示例来源:origin: vakinge/jeesuite-libs
if(configuration.hasStatement(msId))return configuration.getMappedStatement(msId);
代码示例来源:origin: org.apache.ibatis/ibatis-core
private void processGeneratedKeys(Executor executor, MappedStatement ms, Statement stmt, Object parameter) {
try {
final Configuration configuration = ms.getConfiguration();
if (parameter != null) {
String keyStatementName = ms.getId() + SELECT_KEY_SUFFIX;
if (configuration.hasStatement(keyStatementName)) {
if (keyStatement != null) {
String keyProperty = keyStatement.getKeyProperty();
final MetaObject metaParam = configuration.newMetaObject(parameter);
if (keyProperty != null && metaParam.hasSetter(keyProperty)) {
// Do not close keyExecutor.
// The transaction will be closed by parent executor.
Executor keyExecutor = configuration.newExecutor(executor.getTransaction(), ExecutorType.SIMPLE);
List values = keyExecutor.query(keyStatement, parameter, RowBounds.DEFAULT, Executor.NO_RESULT_HANDLER);
if (values.size() > 1) {
throw new ExecutorException("Select statement for SelectKeyGenerator returned more than one value.");
}
metaParam.setValue(keyProperty, values.get(0));
}
}
}
}
} catch (Exception e) {
throw new ExecutorException("Error selecting key or setting result to parameter object. Cause: " + e, e);
}
}
代码示例来源:origin: org.apache.ibatis/ibatis-core
protected void rebindGeneratedKey() {
if (boundSql.getParameterObject() != null) {
String keyStatementName = mappedStatement.getId() + SelectKeyGenerator.SELECT_KEY_SUFFIX;
if (configuration.hasStatement(keyStatementName)) {
MappedStatement keyStatement = configuration.getMappedStatement(keyStatementName);
if (keyStatement != null) {
String keyProperty = keyStatement.getKeyProperty();
MetaObject metaParam = configuration.newMetaObject(boundSql.getParameterObject());
if (keyProperty != null && metaParam.hasSetter(keyProperty) && metaParam.hasGetter(keyProperty)) {
boundSql.setAdditionalParameter(keyProperty, metaParam.getValue(keyProperty));
}
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!