org.apache.ibatis.session.Configuration.hasMapper()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(136)

本文整理了Java中org.apache.ibatis.session.Configuration.hasMapper()方法的一些代码示例,展示了Configuration.hasMapper()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Configuration.hasMapper()方法的具体详情如下:
包路径:org.apache.ibatis.session.Configuration
类名称:Configuration
方法名:hasMapper

Configuration.hasMapper介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

private void retryBindMapperForNamespace() {
  if (!configuration.hasMapper(mapperType)) {
   // Spring may not know the real resource name so we set a flag
   // to prevent loading again this resource from the mapper interface
   // look at MapperAnnotationBuilder#loadXmlResource
   configuration.addLoadedResource("namespace:" + mapperType.getName());
   configuration.addMapper(mapperType);
  }
 }
}

代码示例来源:origin: abel533/Mapper

/**
 * {@inheritDoc}
 */
@Override
protected void checkDaoConfig() {
  super.checkDaoConfig();
  notNull(this.mapperInterface, "Property 'mapperInterface' is required");
  Configuration configuration = getSqlSession().getConfiguration();
  if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) {
    try {
      configuration.addMapper(this.mapperInterface);
    } catch (Exception e) {
      logger.error("Error while adding the mapper '" + this.mapperInterface + "' to configuration.", e);
      throw new IllegalArgumentException(e);
    } finally {
      ErrorContext.instance().reset();
    }
  }
  //直接针对接口处理通用接口方法对应的 MappedStatement 是安全的,通用方法不会出现 IncompleteElementException 的情况
  if (configuration.hasMapper(this.mapperInterface) && mapperHelper != null && mapperHelper.isExtendCommonMapper(this.mapperInterface)) {
    mapperHelper.processConfiguration(getSqlSession().getConfiguration(), this.mapperInterface);
  }
}

代码示例来源:origin: abel533/Mapper

/**
 * {@inheritDoc}
 */
@Override
protected void checkDaoConfig() {
  super.checkDaoConfig();
  notNull(this.mapperInterface, "Property 'mapperInterface' is required");
  Configuration configuration = getSqlSession().getConfiguration();
  if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) {
    try {
      configuration.addMapper(this.mapperInterface);
    } catch (Exception e) {
      logger.error("Error while adding the mapper '" + this.mapperInterface + "' to configuration.", e);
      throw new IllegalArgumentException(e);
    } finally {
      ErrorContext.instance().reset();
    }
  }
  //直接针对接口处理通用接口方法对应的 MappedStatement 是安全的,通用方法不会出现 IncompleteElementException 的情况
  if (configuration.hasMapper(this.mapperInterface) && mapperHelper != null && mapperHelper.isExtendCommonMapper(this.mapperInterface)) {
    mapperHelper.processConfiguration(getSqlSession().getConfiguration(), this.mapperInterface);
  }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void shouldConfigureMyBatis() {
 underTest.start();
 Configuration conf = underTest.getSessionFactory().getConfiguration();
 assertThat(conf.isUseGeneratedKeys(), Is.is(true));
 assertThat(conf.hasMapper(RuleMapper.class), Is.is(true));
 assertThat(conf.isLazyLoadingEnabled(), Is.is(false));
}

代码示例来源:origin: Meituan-Dianping/Zebra

/**
 * {@inheritDoc}
 */
@Override
protected void checkDaoConfig() {
  super.checkDaoConfig();
  notNull(this.mapperInterface, "Property 'mapperInterface' is required");
  Configuration configuration = getSqlSession().getConfiguration();
  if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) {
    try {
      configuration.addMapper(this.mapperInterface);
    } catch (Throwable t) {
      logger.error("Error while adding the mapper '" + this.mapperInterface + "' to configuration.", t);
      throw new IllegalArgumentException(t);
    } finally {
      ErrorContext.instance().reset();
    }
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

private void bindMapperForNamespace() {
 String namespace = builderAssistant.getCurrentNamespace();
 if (namespace != null) {
  Class<?> boundType = null;
  try {
   boundType = Resources.classForName(namespace);
  } catch (ClassNotFoundException e) {
   //ignore, bound type is not required
  }
  if (boundType != null) {
   if (!configuration.hasMapper(boundType)) {
    // Spring may not know the real resource name so we set a flag
    // to prevent loading again this resource from the mapper interface
    // look at MapperAnnotationBuilder#loadXmlResource
    configuration.addLoadedResource("namespace:" + namespace);
    configuration.addMapper(boundType);
   }
  }
 }
}

代码示例来源:origin: org.mybatis/mybatis

private void bindMapperForNamespace() {
 String namespace = builderAssistant.getCurrentNamespace();
 if (namespace != null) {
  Class<?> boundType = null;
  try {
   boundType = Resources.classForName(namespace);
  } catch (ClassNotFoundException e) {
   //ignore, bound type is not required
  }
  if (boundType != null) {
   if (!configuration.hasMapper(boundType)) {
    // Spring may not know the real resource name so we set a flag
    // to prevent loading again this resource from the mapper interface
    // look at MapperAnnotationBuilder#loadXmlResource
    configuration.addLoadedResource("namespace:" + namespace);
    configuration.addMapper(boundType);
   }
  }
 }
}

代码示例来源:origin: makersoft/mybatis-shards

@Override
public boolean hasMapper(Class<?> type) {
  return getConfiguration().hasMapper(type);
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-db

private void retryBindMapperForNamespace() {
  if (!configuration.hasMapper(mapperType)) {
   // Spring may not know the real resource name so we set a flag
   // to prevent loading again this resource from the mapper interface
   // look at MapperAnnotationBuilder#loadXmlResource
   configuration.addLoadedResource("namespace:" + mapperType.getName());
   configuration.addMapper(mapperType);
  }
 }
}

代码示例来源:origin: makersoft/mybatis-shards

@Override
public boolean hasMapper(Class<?> type) {
  for (SqlSessionFactory factory : getSqlSessionFactories()) {
    if (factory.getConfiguration().hasMapper(type)) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: com.gitee.hengboy/mybatis-enhance-core

Assert.notNull(this.mapperInterface, "Property 'mapperInterface' is required");
Configuration configuration = this.getSqlSession().getConfiguration();
if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) {
  try {
if (configuration.hasMapper(this.mapperInterface)) {

代码示例来源:origin: org.apache.ibatis/ibatis-core

private void bindMapperForNamespace() {
 String namespace = builderAssistant.getCurrentNamespace();
 if (namespace != null) {
  Class boundType = null;
  try {
   boundType = Resources.classForName(namespace);
  } catch (ClassNotFoundException e) {
   //ignore, bound type is not required
  }
  if (boundType != null) {
   if (!configuration.hasMapper(boundType)) {
    configuration.addMapper(boundType);
   }
  }
 }
}

代码示例来源:origin: chengdedeng/perseus

/**
 * {@inheritDoc}
 */
@Override
protected void checkDaoConfig() {
  super.checkDaoConfig();
  notNull(this.mapperInterface, "Property 'mapperInterface' is required");
  Configuration configuration = getSqlSession().getConfiguration();
  if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) {
    try {
      configuration.addMapper(this.mapperInterface);
    } catch (Exception e) {
      logger.error("Error while adding the mapper '" + this.mapperInterface + "' to configuration.", e);
      throw new IllegalArgumentException(e);
    } finally {
      ErrorContext.instance().reset();
    }
  }
}

代码示例来源:origin: tk.mybatis/mapper-spring

/**
 * {@inheritDoc}
 */
@Override
protected void checkDaoConfig() {
  super.checkDaoConfig();
  notNull(this.mapperInterface, "Property 'mapperInterface' is required");
  Configuration configuration = getSqlSession().getConfiguration();
  if (this.addToConfig && !configuration.hasMapper(this.mapperInterface)) {
    try {
      configuration.addMapper(this.mapperInterface);
    } catch (Exception e) {
      logger.error("Error while adding the mapper '" + this.mapperInterface + "' to configuration.", e);
      throw new IllegalArgumentException(e);
    } finally {
      ErrorContext.instance().reset();
    }
  }
  //直接针对接口处理通用接口方法对应的 MappedStatement 是安全的,通用方法不会出现 IncompleteElementException 的情况
  if (configuration.hasMapper(this.mapperInterface) && mapperHelper != null && mapperHelper.isExtendCommonMapper(this.mapperInterface)) {
    mapperHelper.processConfiguration(getSqlSession().getConfiguration(), this.mapperInterface);
  }
}

代码示例来源:origin: ldcsaa/JessMA

if(!cfg.hasMapper(clazz))
  cfg.addMapper(clazz);

相关文章

微信公众号

最新文章

更多

Configuration类方法