Examples of SqlSessionFactory


Examples of org.apache.ibatis.session.SqlSessionFactory

  @Test
  public void testGetMessageForEmptyDatabase() throws Exception {
    final Environment environment = new Environment("test", new JdbcTransactionFactory(), BaseDataTest.createBlogDataSource());
    final Configuration config = new Configuration(environment);
    config.addMapper(PostMapper.class);
    final SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(config);
    final SqlSession session = factory.openSession();
   
    PostMapper mapper = session.getMapper(PostMapper.class);
    List<AnnoPost> posts = mapper.getPosts(101);

View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

        new DefaultSqlSessionFactory(configuration);
    }
    @Test
    public void testMixedConfiguration() throws Exception {
      Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/xml_references/ibatisConfig.xml");
      SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
      sqlSessionFactory.getConfiguration().addMapper(PersonMapper2.class);
    }
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

  @Test
  public void shouldDemonstrateDuplicateResourceIssue() throws Exception {
    final String resource = "org/apache/ibatis/submitted/duplicate_resource_loaded/Config.xml";
    final Reader reader = Resources.getResourceAsReader(resource);
    final SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
    final SqlSessionFactory factory = builder.build(reader);
    final SqlSession sqlSession = factory.openSession();
    try {
      final Mapper mapper = sqlSession.getMapper(Mapper.class);
      final List list = mapper.selectAllBlogs();
      Assert.assertEquals(2,list.size());
    } finally {
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

    DataSource ds = BaseDataTest.createBlogDataSource();
    Environment env = new Environment("test",new JdbcTransactionFactory(),ds);
    Configuration config = new Configuration(env);
    config.addMapper(NodeMapper.class);
    SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
    SqlSessionFactory sqlMapper = builder.build(config);
    SqlSession session = sqlMapper.openSession();
    try {
      NodeMapper mapper = session.getMapper(NodeMapper.class);

      try {
        mapper.selectNode(1);
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

    Environment env = new Environment("test",new JdbcTransactionFactory(),ds);
    Configuration config = new Configuration(env);
    config.addMapper(JPetStoreMapper.class);

    SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
    SqlSessionFactory sqlMapper = builder.build(config);
    SqlSession session = sqlMapper.openSession();
    try {
      JPetStoreMapper mapper = session.getMapper(JPetStoreMapper.class);
      int n = mapper.insertCategory("MONKEYS",null,"Big hairy friendly (sometimes) mammals...");
      assertEquals(1,n);
      session.rollback();
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

    Environment env = new Environment("test",new JdbcTransactionFactory(),ds);
    Configuration config = new Configuration(env);
    config.addMapper(BlogMapper.class);

    SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
    SqlSessionFactory sqlMapper = builder.build(config);
    SqlSession session = sqlMapper.openSession();
    try {
      BlogMapper mapper = session.getMapper(BlogMapper.class);
      int n = 0;
      try {
        n = mapper.insertAuthor(new Author(99999,"barney","******","barney@iloveyou.com",null, Section.NEWS));
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

  @Test(expected = PersistenceException.class)
  public void testIncludes() throws Exception {
    String resource = "org/apache/ibatis/submitted/refid_resolution/MapperConfig.xml";
    Reader reader = Resources.getResourceAsReader(resource);
    SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
    SqlSessionFactory sqlSessionFactory = builder.build(reader);
    sqlSessionFactory.getConfiguration().getMappedStatementNames();
  }
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

  }

  private SqlSessionFactory getSqlSessionFactoryXmlConfig() throws Exception {
    Reader configReader = Resources
        .getResourceAsReader("org/apache/ibatis/submitted/xml_external_ref/MultipleReverseIncludeMapperConfig.xml");
    SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(configReader);
    configReader.close();

    Connection conn = sqlSessionFactory.getConfiguration().getEnvironment().getDataSource().getConnection();
    initDb(conn);

    return sqlSessionFactory;
  }
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

public class InsertTest {

    @Test
    public void testInsertAnnotated() throws Exception {
        Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/keycolumn/MapperConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        try {
            InsertMapper mapper = sqlSession.getMapper(InsertMapper.class);
            Name name = new Name();
            name.setFirstName("Fred");
            name.setLastName("Flintstone");
View Full Code Here

Examples of org.apache.ibatis.session.SqlSessionFactory

    }

    @Test
    public void testInsertMapped() throws Exception {
        Reader reader = Resources.getResourceAsReader("org/apache/ibatis/submitted/keycolumn/MapperConfig.xml");
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        try {
            InsertMapper mapper = sqlSession.getMapper(InsertMapper.class);
            Name name = new Name();
            name.setFirstName("Fred");
            name.setLastName("Flintstone");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.