Java Code Examples for org.apache.ibatis.session.Configuration#getMappedStatementNames()

The following examples show how to use org.apache.ibatis.session.Configuration#getMappedStatementNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleCrossIncludeTest.java    From mybaties with Apache License 2.0 6 votes vote down vote up
@Test
public void testMappedStatementCache() throws Exception {
  Reader configReader = Resources
  .getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MultipleCrossIncludeMapperConfig.xml");
  SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
  configReader.close();

  Configuration configuration = sqlSessionFactory.getConfiguration();
  configuration.getMappedStatementNames();
  
  MappedStatement selectPetStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePetMapper.select");
  MappedStatement selectPersonStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePersonMapper.select");
  Cache cache = selectPetStatement.getCache();
  assertEquals("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePetMapper", cache.getId());
  assertSame(cache, selectPersonStatement.getCache());
}
 
Example 2
Source File: XmlExternalRefTest.java    From mybaties with Apache License 2.0 6 votes vote down vote up
@Test
public void testMappedStatementCache() throws Exception {
  Reader configReader = Resources
  .getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MapperConfig.xml");
  SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
  configReader.close();

  Configuration configuration = sqlSessionFactory.getConfiguration();
  configuration.getMappedStatementNames();
  
  MappedStatement selectPetStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.PetMapper.select");
  MappedStatement selectPersonStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.PersonMapper.select");
  Cache cache = selectPetStatement.getCache();
  assertEquals("org.apache.ibatis.submitted.xml_external_ref.PetMapper", cache.getId());
  assertSame(cache, selectPersonStatement.getCache());
}
 
Example 3
Source File: NpeExtendsTest.java    From mybaties with Apache License 2.0 6 votes vote down vote up
private SqlSessionFactory getSqlSessionFactoryWithConstructor() {
    UnpooledDataSourceFactory unpooledDataSourceFactory = new UnpooledDataSourceFactory();
    Properties properties = new Properties();
    properties.setProperty("driver", "org.hsqldb.jdbcDriver");
    properties.setProperty("url", "jdbc:hsqldb:mem:extends_with_constructor");
    properties.setProperty("username", "sa");
    unpooledDataSourceFactory.setProperties(properties);
    Environment environment = new Environment("extends_with_constructor", new JdbcTransactionFactory(), unpooledDataSourceFactory.getDataSource());
    
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.addMapper(StudentConstructorMapper.class);
    configuration.addMapper(TeacherMapper.class);
    configuration.getMappedStatementNames();
    configuration.setAutoMappingBehavior(AutoMappingBehavior.NONE);
    
    return new DefaultSqlSessionFactory(configuration);
}
 
Example 4
Source File: MultipleCrossIncludeTest.java    From mybatis with Apache License 2.0 6 votes vote down vote up
@Test
public void testMappedStatementCache() throws Exception {
  Reader configReader = Resources
  .getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MultipleCrossIncludeMapperConfig.xml");
  SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
  configReader.close();

  Configuration configuration = sqlSessionFactory.getConfiguration();
  configuration.getMappedStatementNames();
  
  MappedStatement selectPetStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePetMapper.select");
  MappedStatement selectPersonStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePersonMapper.select");
  Cache cache = selectPetStatement.getCache();
  assertEquals("org.apache.ibatis.submitted.xml_external_ref.MultipleCrossIncludePetMapper", cache.getId());
  assertSame(cache, selectPersonStatement.getCache());
}
 
Example 5
Source File: XmlExternalRefTest.java    From mybatis with Apache License 2.0 6 votes vote down vote up
@Test
public void testMappedStatementCache() throws Exception {
  Reader configReader = Resources
  .getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MapperConfig.xml");
  SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
  configReader.close();

  Configuration configuration = sqlSessionFactory.getConfiguration();
  configuration.getMappedStatementNames();
  
  MappedStatement selectPetStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.PetMapper.select");
  MappedStatement selectPersonStatement = configuration.getMappedStatement("org.apache.ibatis.submitted.xml_external_ref.PersonMapper.select");
  Cache cache = selectPetStatement.getCache();
  assertEquals("org.apache.ibatis.submitted.xml_external_ref.PetMapper", cache.getId());
  assertSame(cache, selectPersonStatement.getCache());
}
 
Example 6
Source File: NpeExtendsTest.java    From mybatis with Apache License 2.0 6 votes vote down vote up
private SqlSessionFactory getSqlSessionFactoryWithConstructor() {
    UnpooledDataSourceFactory unpooledDataSourceFactory = new UnpooledDataSourceFactory();
    Properties properties = new Properties();
    properties.setProperty("driver", "org.hsqldb.jdbcDriver");
    properties.setProperty("url", "jdbc:hsqldb:mem:extends_with_constructor");
    properties.setProperty("username", "sa");
    unpooledDataSourceFactory.setProperties(properties);
    Environment environment = new Environment("extends_with_constructor", new JdbcTransactionFactory(), unpooledDataSourceFactory.getDataSource());
    
    Configuration configuration = new Configuration();
    configuration.setEnvironment(environment);
    configuration.addMapper(StudentConstructorMapper.class);
    configuration.addMapper(TeacherMapper.class);
    configuration.getMappedStatementNames();
    configuration.setAutoMappingBehavior(AutoMappingBehavior.NONE);
    
    return new DefaultSqlSessionFactory(configuration);
}
 
Example 7
Source File: XmlExternalRefTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test(expected = BuilderException.class)
public void testFailFastOnBuildAll() throws Exception {
  Configuration configuration = new Configuration();
  try {
    configuration.addMapper(InvalidMapper.class);
  } catch (Exception e) {
    fail("No exception should be thrown before parsing statement nodes.");
  }
  configuration.getMappedStatementNames();
}
 
Example 8
Source File: XmlExternalRefTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test(expected = BuilderException.class)
public void testFailFastOnBuildAllWithInsert() throws Exception {
  Configuration configuration = new Configuration();
  try {
    configuration.addMapper(InvalidWithInsertMapper.class);
    configuration.addMapper(InvalidMapper.class);
  } catch (Exception e) {
    fail("No exception should be thrown before parsing statement nodes.");
  }
  configuration.getMappedStatementNames();
}
 
Example 9
Source File: NpeExtendsTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoConstructorConfiguration() {
    Configuration configuration = new Configuration();
    configuration.addMapper(StudentMapper.class);
    configuration.addMapper(TeacherMapper.class);
    configuration.getMappedStatementNames();
}
 
Example 10
Source File: NpeExtendsTest.java    From mybaties with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithConstructorConfiguration() {
    Configuration configuration = new Configuration();
    configuration.addMapper(StudentConstructorMapper.class);
    configuration.addMapper(TeacherMapper.class);
    configuration.getMappedStatementNames();
}
 
Example 11
Source File: XmlExternalRefTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test(expected = BuilderException.class)
public void testFailFastOnBuildAll() throws Exception {
  Configuration configuration = new Configuration();
  try {
    configuration.addMapper(InvalidMapper.class);
  } catch (Exception e) {
    fail("No exception should be thrown before parsing statement nodes.");
  }
  configuration.getMappedStatementNames();
}
 
Example 12
Source File: XmlExternalRefTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test(expected = BuilderException.class)
public void testFailFastOnBuildAllWithInsert() throws Exception {
  Configuration configuration = new Configuration();
  try {
    configuration.addMapper(InvalidWithInsertMapper.class);
    configuration.addMapper(InvalidMapper.class);
  } catch (Exception e) {
    fail("No exception should be thrown before parsing statement nodes.");
  }
  configuration.getMappedStatementNames();
}
 
Example 13
Source File: NpeExtendsTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoConstructorConfiguration() {
    Configuration configuration = new Configuration();
    configuration.addMapper(StudentMapper.class);
    configuration.addMapper(TeacherMapper.class);
    configuration.getMappedStatementNames();
}
 
Example 14
Source File: NpeExtendsTest.java    From mybatis with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithConstructorConfiguration() {
    Configuration configuration = new Configuration();
    configuration.addMapper(StudentConstructorMapper.class);
    configuration.addMapper(TeacherMapper.class);
    configuration.getMappedStatementNames();
}