use of org.apache.ibatis.builder.xml.XMLMapperBuilder in project mybatis-3 by mybatis.
the class XmlMapperBuilderTest method shouldSuccessfullyLoadXMLMapperFile.
@Test
public void shouldSuccessfullyLoadXMLMapperFile() throws Exception {
Configuration configuration = new Configuration();
String resource = "org/apache/ibatis/builder/AuthorMapper.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
XMLMapperBuilder builder = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments());
builder.parse();
}
use of org.apache.ibatis.builder.xml.XMLMapperBuilder in project mybatis-3 by mybatis.
the class MapperAnnotationBuilder method loadXmlResource.
private void loadXmlResource() {
// this flag is set at XMLMapperBuilder#bindMapperForNamespace
if (!configuration.isResourceLoaded("namespace:" + type.getName())) {
String xmlResource = type.getName().replace('.', '/') + ".xml";
InputStream inputStream = null;
try {
inputStream = Resources.getResourceAsStream(type.getClassLoader(), xmlResource);
} catch (IOException e) {
// ignore, resource is not required
}
if (inputStream != null) {
XMLMapperBuilder xmlParser = new XMLMapperBuilder(inputStream, assistant.getConfiguration(), xmlResource, configuration.getSqlFragments(), type.getName());
xmlParser.parse();
}
}
}
use of org.apache.ibatis.builder.xml.XMLMapperBuilder in project sonarqube by SonarSource.
the class MyBatisConfBuilder method loadMapper.
public void loadMapper(String mapperName) {
String configFile = configFilePath(mapperName);
InputStream input = null;
try {
input = getClass().getResourceAsStream(configFile);
checkArgument(input != null, format("Can not find mapper XML file %s", configFile));
new XMLMapperBuilder(input, conf, mapperName, conf.getSqlFragments()).parse();
loadAndConfigureLogger(mapperName);
} catch (Exception e) {
throw new IllegalArgumentException("Unable to load mapper " + mapperName, e);
} finally {
Closeables.closeQuietly(input);
}
}
use of org.apache.ibatis.builder.xml.XMLMapperBuilder in project mybatis-3 by mybatis.
the class XmlMapperBuilderTest method mappedStatementWithOptions.
@Test
public void mappedStatementWithOptions() throws Exception {
Configuration configuration = new Configuration();
String resource = "org/apache/ibatis/builder/AuthorMapper.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
XMLMapperBuilder builder = new XMLMapperBuilder(inputStream, configuration, resource, configuration.getSqlFragments());
builder.parse();
MappedStatement mappedStatement = configuration.getMappedStatement("selectWithOptions");
assertThat(mappedStatement.getFetchSize(), is(200));
assertThat(mappedStatement.getTimeout(), is(10));
assertThat(mappedStatement.getStatementType(), is(StatementType.PREPARED));
assertThat(mappedStatement.getResultSetType(), is(ResultSetType.SCROLL_SENSITIVE));
assertThat(mappedStatement.isFlushCacheRequired(), is(false));
assertThat(mappedStatement.isUseCache(), is(false));
}
Aggregations