Search in sources :

Example 26 with Pkfields

use of mbg.test.ib2j2.generated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testPKFieldsSelectByExampleNoCriteria.

@Test
public void testPKFieldsSelectByExampleNoCriteria() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Fred");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(1);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Wilma");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(2);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Pebbles");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(3);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Barney");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(1);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Betty");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(2);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Bamm Bamm");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(3);
        mapper.insert(record);
        PkfieldsExample example = new PkfieldsExample();
        example.createCriteria();
        example.setOrderByClause("ID1, ID2");
        List<Pkfields> answer = mapper.selectByExample(example);
        assertEquals(6, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.flat.model.Pkfields) PkfieldsExample(mbg.test.mb3.generated.flat.model.PkfieldsExample) Test(org.junit.Test)

Example 27 with Pkfields

use of mbg.test.ib2j2.generated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testEquals3.

@Test
public void testEquals3() {
    Pkfields pkfields1 = new Pkfields();
    pkfields1.setId1(2);
    Pkfields pkfields2 = new Pkfields();
    pkfields2.setId1(2);
    assertTrue(pkfields1.equals(pkfields2));
}
Also used : Pkfields(mbg.test.mb3.generated.flat.model.Pkfields) Test(org.junit.Test)

Example 28 with Pkfields

use of mbg.test.ib2j2.generated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testPKfieldsDeleteByPrimaryKey.

@Test
public void testPKfieldsDeleteByPrimaryKey() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setId1(1);
        record.setId2(2);
        mapper.insert(record);
        int rows = mapper.deleteByPrimaryKey(2, 1);
        assertEquals(1, rows);
        PkfieldsExample example = new PkfieldsExample();
        List<Pkfields> answer = mapper.selectByExample(example);
        assertEquals(0, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.flat.model.Pkfields) PkfieldsExample(mbg.test.mb3.generated.flat.model.PkfieldsExample) Test(org.junit.Test)

Example 29 with Pkfields

use of mbg.test.ib2j2.generated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testPKFieldsSelectByExampleBetween.

@Test
public void testPKFieldsSelectByExampleBetween() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Fred");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(1);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Wilma");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(2);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Pebbles");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(3);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Barney");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(1);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Betty");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(2);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Bamm Bamm");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(3);
        mapper.insert(record);
        PkfieldsExample example = new PkfieldsExample();
        example.createCriteria().andId2Between(1, 3);
        example.setOrderByClause("ID1, ID2");
        List<Pkfields> answer = mapper.selectByExample(example);
        assertEquals(6, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.flat.model.Pkfields) PkfieldsExample(mbg.test.mb3.generated.flat.model.PkfieldsExample) Test(org.junit.Test)

Example 30 with Pkfields

use of mbg.test.ib2j2.generated.flat.model.Pkfields in project generator by mybatis.

the class FlatJava5Test method testPKFieldsDeleteByExample.

@Test
public void testPKFieldsDeleteByExample() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setId1(1);
        record.setId2(2);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Bob");
        record.setLastname("Jones");
        record.setId1(3);
        record.setId2(4);
        mapper.insert(record);
        PkfieldsExample example = new PkfieldsExample();
        List<Pkfields> answer = mapper.selectByExample(example);
        assertEquals(2, answer.size());
        example = new PkfieldsExample();
        example.createCriteria().andLastnameLike("J%");
        int rows = mapper.deleteByExample(example);
        assertEquals(1, rows);
        example = new PkfieldsExample();
        answer = mapper.selectByExample(example);
        assertEquals(1, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.flat.model.Pkfields) PkfieldsExample(mbg.test.mb3.generated.flat.model.PkfieldsExample) Test(org.junit.Test)

Aggregations

SQLException (java.sql.SQLException)48 Test (org.junit.Test)45 ArrayList (java.util.ArrayList)29 List (java.util.List)27 Pkfields (mbg.test.mb3.generated.flat.model.Pkfields)23 Pkfields (mbg.test.ib2j5.generated.flat.model.Pkfields)22 PkfieldsMapper (mbg.test.mb3.generated.flat.mapper.PkfieldsMapper)17 SqlSession (org.apache.ibatis.session.SqlSession)17 PkfieldsDAO (mbg.test.ib2j2.generated.conditional.dao.PkfieldsDAO)16 Pkfields (mbg.test.ib2j2.generated.conditional.model.Pkfields)16 PkfieldsDAO (mbg.test.ib2j2.generated.flat.dao.PkfieldsDAO)16 Pkfields (mbg.test.ib2j2.generated.flat.model.Pkfields)16 PkfieldsDAO (mbg.test.ib2j2.generated.hierarchical.dao.PkfieldsDAO)16 Pkfields (mbg.test.ib2j2.generated.hierarchical.model.Pkfields)16 PkfieldsDAO (mbg.test.ib2j5.generated.flat.dao.PkfieldsDAO)16 PkfieldsExample (mbg.test.mb3.generated.flat.model.PkfieldsExample)13 PkfieldsExample (mbg.test.ib2j2.generated.conditional.model.PkfieldsExample)12 PkfieldsExample (mbg.test.ib2j2.generated.flat.model.PkfieldsExample)12 PkfieldsExample (mbg.test.ib2j2.generated.hierarchical.model.PkfieldsExample)12 PkfieldsExample (mbg.test.ib2j5.generated.flat.model.PkfieldsExample)12