List of usage examples for org.apache.ibatis.session Configuration addLoadedResource
public void addLoadedResource(String resource)
From source file:org.neo4j.jdbc.example.mybatis.MybatisTest.java
License:Apache License
protected void buildMybatisConfiguration(String protocol, String host, int port) { DataSource dataSource = new UnpooledDataSource("org.neo4j.jdbc.Driver", "jdbc:neo4j:" + protocol + "://" + host + ":" + port + "?noSsl", null); TransactionFactory transactionFactory = new JdbcTransactionFactory(); Environment environment = new Environment("development", transactionFactory, dataSource); Configuration configuration = new Configuration(environment); configuration.getMapperRegistry().addMapper(ActorMapper.class); configuration.addLoadedResource("org/neo4j/jdbc/example/mybatis/mapper/ActorMapper.xml"); ConnectionFactory.getSqlSessionFactory(configuration); }
From source file:org.sonar.core.persistence.MyBatis.java
License:Open Source License
private void loadMapper(Configuration configuration, String mapperName) { InputStream input = null;//from ww w.j a v a 2s . co m try { input = getClass().getResourceAsStream("/" + mapperName.replace('.', '/') + ".xml"); new XMLMapperBuilder(input, configuration, mapperName, configuration.getSqlFragments()).parse(); configuration.addLoadedResource(mapperName); } catch (Exception e) { throw new IllegalArgumentException("Unable to load mapper " + mapperName, e); } finally { Closeables.closeQuietly(input); } }