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

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

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

Configuration.getVariables介绍

暂无

代码示例

代码示例来源:origin: baomidou/mybatis-plus

private Properties convertToProperties(Property[] properties) {
  if (properties.length == 0) {
    return null;
  }
  Properties props = new Properties();
  for (Property property : properties) {
    props.setProperty(property.name(),
      PropertyParser.parse(property.value(), configuration.getVariables()));
  }
  return props;
}

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

MyBatisConfBuilder(Database database) {
 this.conf = new Configuration();
 this.conf.setEnvironment(new Environment("production", createTransactionFactory(), database.getDataSource()));
 this.conf.setUseGeneratedKeys(true);
 this.conf.setLazyLoadingEnabled(false);
 this.conf.setJdbcTypeForNull(JdbcType.NULL);
 Dialect dialect = database.getDialect();
 this.conf.setDatabaseId(dialect.getId());
 this.conf.getVariables().setProperty("_true", dialect.getTrueSqlValue());
 this.conf.getVariables().setProperty("_false", dialect.getFalseSqlValue());
 this.conf.getVariables().setProperty("_from_dual", dialect.getSqlFromDual());
 this.conf.getVariables().setProperty("_scrollFetchSize", String.valueOf(dialect.getScrollDefaultFetchSize()));
 this.conf.setLocalCacheScope(LocalCacheScope.STATEMENT);
}

代码示例来源:origin: baomidou/mybatis-plus

private void propertiesElement(XNode context) throws Exception {
  if (context != null) {
    Properties defaults = context.getChildrenAsProperties();
    String resource = context.getStringAttribute("resource");
    String url = context.getStringAttribute("url");
    if (resource != null && url != null) {
      throw new BuilderException("The properties element cannot specify both a URL and a resource based property file reference.  Please specify one or the other.");
    }
    if (resource != null) {
      defaults.putAll(Resources.getResourceAsProperties(resource));
    } else if (url != null) {
      defaults.putAll(Resources.getUrlAsProperties(url));
    }
    Properties vars = configuration.getVariables();
    if (vars != null) {
      defaults.putAll(vars);
    }
    parser.setVariables(defaults);
    configuration.setVariables(defaults);
  }
}

代码示例来源:origin: baomidou/mybatis-plus

loadedResourcesField.setAccessible(true);
Set loadedResourcesSet = ((Set) loadedResourcesField.get(configuration));
XPathParser xPathParser = new XPathParser(resource.getInputStream(), true, configuration.getVariables(),
  new XMLMapperEntityResolver());
XNode context = xPathParser.evalNode("/mapper");

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

public void applyIncludes(Node source) {
 Properties variablesContext = new Properties();
 Properties configurationVariables = configuration.getVariables();
 if (configurationVariables != null) {
  variablesContext.putAll(configurationVariables);
 }
 applyIncludes(source, variablesContext, false);
}

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

public void applyIncludes(Node source) {
 Properties variablesContext = new Properties();
 Properties configurationVariables = configuration.getVariables();
 if (configurationVariables != null) {
  variablesContext.putAll(configurationVariables);
 }
 applyIncludes(source, variablesContext, false);
}

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

private String replacePlaceholder(String sql) {
 return PropertyParser.parse(sql, configuration.getVariables());
}

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

private Properties convertToProperties(Property[] properties) {
 if (properties.length == 0) {
  return null;
 }
 Properties props = new Properties();
 for (Property property : properties) {
  props.setProperty(property.name(),
    PropertyParser.parse(property.value(), configuration.getVariables()));
 }
 return props;
}

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

private Properties convertToProperties(Property[] properties) {
 if (properties.length == 0) {
  return null;
 }
 Properties props = new Properties();
 for (Property property : properties) {
  props.setProperty(property.name(),
    PropertyParser.parse(property.value(), configuration.getVariables()));
 }
 return props;
}

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

@Deprecated
public XMLMapperBuilder(Reader reader, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
 this(new XPathParser(reader, true, configuration.getVariables(), new XMLMapperEntityResolver()),
   configuration, resource, sqlFragments);
}

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

@Deprecated
public XMLMapperBuilder(Reader reader, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
 this(new XPathParser(reader, true, configuration.getVariables(), new XMLMapperEntityResolver()),
   configuration, resource, sqlFragments);
}

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

public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
 this(new XPathParser(inputStream, true, configuration.getVariables(), new XMLMapperEntityResolver()),
   configuration, resource, sqlFragments);
}

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

public XMLMapperBuilder(InputStream inputStream, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
 this(new XPathParser(inputStream, true, configuration.getVariables(), new XMLMapperEntityResolver()),
   configuration, resource, sqlFragments);
}

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

@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
 // issue #3
 if (script.startsWith("<script>")) {
  XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
  return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
 } else {
  // issue #127
  script = PropertyParser.parse(script, configuration.getVariables());
  TextSqlNode textSqlNode = new TextSqlNode(script);
  if (textSqlNode.isDynamic()) {
   return new DynamicSqlSource(configuration, textSqlNode);
  } else {
   return new RawSqlSource(configuration, script, parameterType);
  }
 }
}

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

private void propertiesElement(XNode context) throws Exception {
 if (context != null) {
  Properties defaults = context.getChildrenAsProperties();
  String resource = context.getStringAttribute("resource");
  String url = context.getStringAttribute("url");
  if (resource != null && url != null) {
   throw new BuilderException("The properties element cannot specify both a URL and a resource based property file reference.  Please specify one or the other.");
  }
  if (resource != null) {
   defaults.putAll(Resources.getResourceAsProperties(resource));
  } else if (url != null) {
   defaults.putAll(Resources.getUrlAsProperties(url));
  }
  Properties vars = configuration.getVariables();
  if (vars != null) {
   defaults.putAll(vars);
  }
  parser.setVariables(defaults);
  configuration.setVariables(defaults);
 }
}

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

@Override
public SqlSource createSqlSource(Configuration configuration, String script, Class<?> parameterType) {
 // issue #3
 if (script.startsWith("<script>")) {
  XPathParser parser = new XPathParser(script, false, configuration.getVariables(), new XMLMapperEntityResolver());
  return createSqlSource(configuration, parser.evalNode("/script"), parameterType);
 } else {
  // issue #127
  script = PropertyParser.parse(script, configuration.getVariables());
  TextSqlNode textSqlNode = new TextSqlNode(script);
  if (textSqlNode.isDynamic()) {
   return new DynamicSqlSource(configuration, textSqlNode);
  } else {
   return new RawSqlSource(configuration, script, parameterType);
  }
 }
}

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

private void propertiesElement(XNode context) throws Exception {
 if (context != null) {
  Properties defaults = context.getChildrenAsProperties();
  String resource = context.getStringAttribute("resource");
  String url = context.getStringAttribute("url");
  if (resource != null && url != null) {
   throw new BuilderException("The properties element cannot specify both a URL and a resource based property file reference.  Please specify one or the other.");
  }
  if (resource != null) {
   defaults.putAll(Resources.getResourceAsProperties(resource));
  } else if (url != null) {
   defaults.putAll(Resources.getUrlAsProperties(url));
  }
  Properties vars = configuration.getVariables();
  if (vars != null) {
   defaults.putAll(vars);
  }
  parser.setVariables(defaults);
  configuration.setVariables(defaults);
 }
}

代码示例来源:origin: com.gitee.zhaohuihua/bdp-general-svc

public static Dialect buildDialect(Configuration configuration) {
    if (dialectClass == null) {
      synchronized (DialectFactory.class) {
        if (dialectClass == null) {
          dialectClass = configuration.getVariables().getProperty("dialectClass");
        }
      }
    }
    if (dialect != null) {
      return dialect;
    }
    try {
      dialect = (Dialect) Class.forName(dialectClass).newInstance();
    } catch (Exception e) {
      e.printStackTrace();
      System.err.println("请检查 mybatis-config.xml 中  dialectClass 是否配置正确?");
    }
    return dialect;
  }
}

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

public MyBatisConfBuilder(Database database) {
 this.conf = new Configuration();
 this.conf.setEnvironment(new Environment("production", createTransactionFactory(), database.getDataSource()));
 this.conf.setUseGeneratedKeys(true);
 this.conf.setLazyLoadingEnabled(false);
 this.conf.setJdbcTypeForNull(JdbcType.NULL);
 Dialect dialect = database.getDialect();
 this.conf.setDatabaseId(dialect.getId());
 this.conf.getVariables().setProperty("_true", dialect.getTrueSqlValue());
 this.conf.getVariables().setProperty("_false", dialect.getFalseSqlValue());
 this.conf.getVariables().setProperty("_scrollFetchSize", String.valueOf(dialect.getScrollDefaultFetchSize()));
 this.conf.setLocalCacheScope(LocalCacheScope.STATEMENT);
}

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

public XMLMapperBuilder(Reader reader, Configuration configuration, String resource, Map<String, XNode> sqlFragments) {
 super(configuration);
 this.builderAssistant = new MapperBuilderAssistant(configuration, resource);
 this.parser = new XPathParser(reader, true, new XMLMapperEntityResolver(), configuration.getVariables());
 this.sqlFragments = sqlFragments;
 this.resource = resource;
}

相关文章

微信公众号

最新文章

更多

Configuration类方法