Package org.apache.ibatis.session

Examples of org.apache.ibatis.session.SqlSession


            {new Person(1, "Kevin", 30, "Coder"), new Person(2, "Vivian", 30, "Wife"),
                    new Person(3, "Kitty", 2, "Daughter")};

    @Test
    public void testSelect1() {
        SqlSession tdhsSession = getTDHSSession();
        Person tdhsPerson = tdhsSession.getMapper(PersonMapper.class).selectPerson(2);
        assertEquals(data[1], tdhsPerson);
        SqlSession mysqlSession = getTDHSSession();
        Person mysqlPerson = mysqlSession.getMapper(PersonMapper.class).selectPerson(2);
        assertEquals(mysqlPerson, tdhsPerson);
        tdhsSession.close();
        mysqlSession.close();
    }
View Full Code Here


        mysqlSession.close();
    }

    @Test
    public void testSelect2() {
        SqlSession tdhsSession = getTDHSSession();
        Person tdhsPerson = tdhsSession.getMapper(PersonMapper.class).selectPerson(3);
        assertEquals(data[2], tdhsPerson);
        SqlSession mysqlSession = getTDHSSession();
        Person mysqlPerson = mysqlSession.getMapper(PersonMapper.class).selectPerson(3);
        assertEquals(mysqlPerson, tdhsPerson);
        tdhsSession.close();
        mysqlSession.close();
    }
View Full Code Here

        mysqlSession.close();
    }

    @Test
    public void testSelect3() {
        SqlSession tdhsSession = getTDHSSession();
        List<Person> tdhsPerson = tdhsSession.getMapper(PersonMapper.class).selectPersons(1);
        SqlSession mysqlSession = getTDHSSession();
        List<Person> mysqlPerson = mysqlSession.getMapper(PersonMapper.class).selectPersons(1);
        compareRecord(mysqlPerson, tdhsPerson);
        tdhsSession.close();
        mysqlSession.close();
    }
View Full Code Here

        mysqlSession.close();
    }

    @Test
    public void testSelect4() {
        SqlSession tdhsSession = getTDHSSession();
        List<Person> tdhsPerson = tdhsSession.getMapper(PersonMapper.class).selectPersons(-1);
        SqlSession mysqlSession = getTDHSSession();
        List<Person> mysqlPerson = mysqlSession.getMapper(PersonMapper.class).selectPersons(-1);
        compareRecord(mysqlPerson, tdhsPerson);
        tdhsSession.close();
        mysqlSession.close();
    }
View Full Code Here

    }


    @Test
    public void testInset() {
        SqlSession tdhsSession = getTDHSSession();
        for (OrderVO orderVO : DATA) {
            int insert = tdhsSession.getMapper(OrderMapper.class).insert(orderVO);
            assertEquals(1, insert);
        }
        tdhsSession.close();
    }
View Full Code Here

        tdhsSession.close();
    }

    @Test
    public void testInsertDone() {
        SqlSession tdhsSession = getTDHSSession();
        List<OrderVO> orderVOs = tdhsSession.getMapper(OrderMapper.class).selectAll();
        compareRecord(DATA, orderVOs);
        tdhsSession.close();
    }
View Full Code Here

        tdhsSession.close();
    }

    @Test
    public void testSelect1() throws ClassNotFoundException, SQLException {
        SqlSession tdhsSession = getTDHSSession();
        SqlSession mySQLSession = getMySQLSession();
        List<OrderVO> tdhsOrderVOs = tdhsSession.getMapper(OrderMapper.class).selectGreaterthanId(0);
        List<OrderVO> mysqlOrderVOs = mySQLSession.getMapper(OrderMapper.class).selectGreaterthanId(0);
        compareRecord(mysqlOrderVOs, tdhsOrderVOs);
        tdhsSession.close();
        mySQLSession.close();
    }
View Full Code Here

    }
  }

  @Test
  public void testEncoding1() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
      EncodingMapper mapper = sqlSession.getMapper(EncodingMapper.class);
      String answer = mapper.select1();
      assertEquals("Mara\u00f1\u00f3n", answer);
    } finally {
      sqlSession.close();
    }
  }
View Full Code Here

    }
  }

  @Test
  public void testEncoding2() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
      EncodingMapper mapper = sqlSession.getMapper(EncodingMapper.class);
      String answer = mapper.select2();
      assertEquals("Mara\u00f1\u00f3n", answer);
    } finally {
      sqlSession.close();
    }
  }
View Full Code Here

        }
    }

    @Test
    public void testLoadLazyImmutablePOJO() {
        final SqlSession session = factory.openSession();
        try {
            final ImmutablePOJOMapper mapper = session.getMapper(ImmutablePOJOMapper.class);
            final ImmutablePOJO pojo = mapper.getImmutablePOJO(POJO_ID);

            assertEquals(POJO_ID, pojo.getId());
            assertNotNull("Description should not be null.", pojo.getDescription());
            assertFalse("Description should not be empty.", pojo.getDescription().length() == 0);
        } finally {
            session.close();
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.ibatis.session.SqlSession

Copyright © 2018 www.massapicom. 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.