public Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
private SqlSessionFactory buildSqlSessionFactory() throws IOException { SqlSessionFactoryBuilder factoryBuilder = new SqlSessionFactoryBuilder(); Configuration baseConfiguration = new XMLConfigBuilder(configLocation.getInputStream()).parse(); String ibatisConfigXmlLocation = databaseStrategy.getIbatisConfigXmlLocation(); if (isNotBlank(ibatisConfigXmlLocation)) { XMLConfigBuilder builder = new XMLConfigBuilder(new ClassPathResource(ibatisConfigXmlLocation).getInputStream()); // hacky way to "inject" a previous configuration Field configurationField = ReflectionUtils.findField(XMLConfigBuilder.class, "configuration"); ReflectionUtils.makeAccessible(configurationField); ReflectionUtils.setField(configurationField, builder, baseConfiguration); baseConfiguration = builder.parse(); } baseConfiguration.setEnvironment(new Environment(getClass().getSimpleName(), new SpringManagedTransactionFactory(), this.dataSource)); return factoryBuilder.build(baseConfiguration); }
public SqlSessionFactory build(Reader reader, String environment, Properties properties) { try { XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, properties); return build(parser.parse()); } catch (Exception e) { throw ExceptionFactory.wrapException("Error building SqlSession.", e); } finally { ErrorContext.instance().reset(); try { reader.close(); } catch (IOException e) { // Intentionally ignore. Prefer previous error. } } }
public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) { try { XMLConfigBuilder parser = new XMLConfigBuilder(inputStream, environment, properties); return build(parser.parse()); } catch (Exception e) { throw ExceptionFactory.wrapException("Error building SqlSession.", e); } finally { ErrorContext.instance().reset(); try { inputStream.close(); } catch (IOException e) { // Intentionally ignore. Prefer previous error. } } }
public SqlSessionFactory build(InputStream inputStream, String environment, Properties properties) { try { XMLConfigBuilder parser = new XMLConfigBuilder(inputStream, environment, properties); return build(parser.parse()); } catch (Exception e) { throw ExceptionFactory.wrapException("Error building SqlSession.", e); } finally { ErrorContext.instance().reset(); try { inputStream.close(); } catch (IOException e) { // Intentionally ignore. Prefer previous error. } } }
public SqlSessionFactory build(Reader reader, String environment, Properties properties) { try { XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, properties); return build(parser.parse()); } catch (Exception e) { throw ExceptionFactory.wrapException("Error building SqlSession.", e); } finally { ErrorContext.instance().reset(); try { reader.close(); } catch (IOException e) { // Intentionally ignore. Prefer previous error. } } }
Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration = parser.parse();
Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration = parser.parse();
public Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
protected Configuration parseMybatisConfiguration(Configuration configuration, XMLConfigBuilder parser) { return parseCustomMybatisXMLMappers(parser.parse()); }
public SqlSessionFactory build(Reader reader, String environment, Properties properties) { try { XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, properties); return build(parser.parse()); ...
protected void initSqlSessionFactory() { if (sqlSessionFactory==null) { InputStream inputStream = null; try { inputStream = getMyBatisXmlConfigurationSteam(); // update the jdbc parameters to the configured ones... Environment environment = new Environment("default", transactionFactory, dataSource); Reader reader = new InputStreamReader(inputStream); Properties properties = new Properties(); properties.put("prefix", databaseTablePrefix); if(databaseType != null) { properties.put("limitBefore" , DbSqlSessionFactory.databaseSpecificLimitBeforeStatements.get(databaseType)); properties.put("limitAfter" , DbSqlSessionFactory.databaseSpecificLimitAfterStatements.get(databaseType)); properties.put("limitBetween" , DbSqlSessionFactory.databaseSpecificLimitBetweenStatements.get(databaseType)); properties.put("orderBy" , DbSqlSessionFactory.databaseSpecificOrderByStatements.get(databaseType)); } XMLConfigBuilder parser = new XMLConfigBuilder(reader,"", properties); Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler()); configuration = parser.parse(); sqlSessionFactory = new DefaultSqlSessionFactory(configuration); } catch (Exception e) { throw new ActivitiException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e); } finally { IoUtil.closeSilently(inputStream); } } }
protected void initSqlSessionFactory() { if (sqlSessionFactory==null) { InputStream inputStream = null; try { inputStream = getMyBatisXmlConfigurationSteam(); // update the jdbc parameters to the configured ones... Environment environment = new Environment("default", transactionFactory, dataSource); Reader reader = new InputStreamReader(inputStream); Properties properties = new Properties(); properties.put("prefix", databaseTablePrefix); if(databaseType != null) { properties.put("limitBefore" , DbSimulatorSqlSessionFactory.databaseSpecificLimitBeforeStatements.get(databaseType)); properties.put("limitAfter" , DbSimulatorSqlSessionFactory.databaseSpecificLimitAfterStatements.get(databaseType)); properties.put("limitBetween" , DbSimulatorSqlSessionFactory.databaseSpecificLimitBetweenStatements.get(databaseType)); properties.put("orderBy" , DbSimulatorSqlSessionFactory.databaseSpecificOrderByStatements.get(databaseType)); } XMLConfigBuilder parser = new XMLConfigBuilder(reader,"", properties); Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler()); configuration = parser.parse(); sqlSessionFactory = new DefaultSqlSessionFactory(configuration); } catch (Exception e) { throw new ActivitiException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e); } finally { IoUtil.closeSilently(inputStream); } } }
public SqlSessionFactory build(Reader reader, String environment, Properties props) { try { XMLConfigBuilder parser = new XMLConfigBuilder(reader, environment, props); Configuration config = parser.parse(); return build(config); } catch (Exception e) { throw ExceptionFactory.wrapException("Error building SqlSession.", e); } finally { ErrorContext.instance().reset(); try { reader.close(); } catch (IOException e) { // Intentionally ignore. Prefer previous error. } } }
Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration = parser.parse();
public Configuration parseMybatisConfiguration(XMLConfigBuilder parser) { Configuration configuration = parser.parse(); if (dependentEngineMybatisTypeAliasConfigs != null) { for (MybatisTypeAliasConfigurator typeAliasConfig : dependentEngineMybatisTypeAliasConfigs) { typeAliasConfig.configure(configuration.getTypeAliasRegistry()); } } if (dependentEngineMybatisTypeHandlerConfigs != null) { for (MybatisTypeHandlerConfigurator typeHandlerConfig : dependentEngineMybatisTypeHandlerConfigs) { typeHandlerConfig.configure(configuration.getTypeHandlerRegistry()); } } parseDependentEngineMybatisXMLMappers(configuration); parseCustomMybatisXMLMappers(configuration); return configuration; }
@Override protected void initSqlSessionFactory() { if (sqlSessionFactory == null) { InputStream inputStream = null; try { inputStream = ReflectUtil.getResourceAsStream("org/aperteworkflow/ext/activiti/mybatis/mappings-enhanced.xml"); // update the jdbc parameters to the configured ones... Environment environment = new Environment("default", transactionFactory, dataSource); Reader reader = new InputStreamReader(inputStream); XMLConfigBuilder parser = new XMLConfigBuilder(reader); Configuration configuration = parser.getConfiguration(); configuration.setEnvironment(environment); configuration.getTypeHandlerRegistry().register(VariableType.class, JdbcType.VARCHAR, new IbatisVariableTypeHandler()); configuration = parser.parse(); sqlSessionFactory = new DefaultSqlSessionFactory(configuration); } catch (Exception e) { throw new ActivitiException("Error while building ibatis SqlSessionFactory: " + e.getMessage(), e); } finally { IoUtil.closeSilently(inputStream); } } } }
public Configuration parseMybatisConfiguration(XMLConfigBuilder parser) { Configuration configuration = parser.parse(); if (dependentEngineMybatisTypeAliasConfigs != null) { for (CustomMybatisTypeAliasConfig typeAliasConfig : dependentEngineMybatisTypeAliasConfigs) { configuration.getTypeAliasRegistry().registerAlias(typeAliasConfig.getAliasName(), typeAliasConfig.getTypeHandlerClass()); } } if (dependentEngineMybatisTypeHandlerConfigs != null) { for (CustomMyBatisTypeHandlerConfig typeHandlerConfig : dependentEngineMybatisTypeHandlerConfigs) { configuration.getTypeHandlerRegistry().register(typeHandlerConfig.getJavaTypeClass(), typeHandlerConfig.getJdbcType(), typeHandlerConfig.getTypeHandlerClass()); } } parseDependentEngineMybatisXMLMappers(configuration); parseCustomMybatisXMLMappers(configuration); return configuration; }