Search in sources :

Example 36 with AwfulTableExample

use of mbg.test.mb3.generated.flat.model.AwfulTableExample in project generator by mybatis.

the class FlatJava5Test method testAwfulTableSelectByExampleBetween.

@Test
public void testAwfulTableSelectByExampleBetween() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
        AwfulTable record = new AwfulTable();
        record.seteMail("fred@fred.com");
        record.setEmailaddress("alsofred@fred.com");
        record.setFirstFirstName("fred1");
        record.setFrom("from field");
        record.setId1(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(7);
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("wilma@wilma.com");
        record.setEmailaddress("alsoWilma@wilma.com");
        record.setFirstFirstName("wilma1");
        record.setFrom("from field");
        record.setId1(11);
        record.setId2(22);
        record.setId5(55);
        record.setId6(66);
        record.setId7(77);
        record.setSecondFirstName("wilma2");
        record.setThirdFirstName("wilma3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("pebbles@pebbles.com");
        record.setEmailaddress("alsoPebbles@pebbles.com");
        record.setFirstFirstName("pebbles1");
        record.setFrom("from field");
        record.setId1(111);
        record.setId2(222);
        record.setId5(555);
        record.setId6(666);
        record.setId7(777);
        record.setSecondFirstName("pebbles2");
        record.setThirdFirstName("pebbles3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("barney@barney.com");
        record.setEmailaddress("alsoBarney@barney.com");
        record.setFirstFirstName("barney1");
        record.setFrom("from field");
        record.setId1(1111);
        record.setId2(2222);
        record.setId5(5555);
        record.setId6(6666);
        record.setId7(7777);
        record.setSecondFirstName("barney2");
        record.setThirdFirstName("barney3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("betty@betty.com");
        record.setEmailaddress("alsoBetty@betty.com");
        record.setFirstFirstName("betty1");
        record.setFrom("from field");
        record.setId1(11111);
        record.setId2(22222);
        record.setId5(55555);
        record.setId6(66666);
        record.setId7(77777);
        record.setSecondFirstName("betty2");
        record.setThirdFirstName("betty3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("bammbamm@bammbamm.com");
        record.setEmailaddress("alsoBammbamm@bammbamm.com");
        record.setFirstFirstName("bammbamm1");
        record.setFrom("from field");
        record.setId1(111111);
        record.setId2(222222);
        record.setId5(555555);
        record.setId6(666666);
        record.setId7(777777);
        record.setSecondFirstName("bammbamm2");
        record.setThirdFirstName("bammbamm3");
        mapper.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria().andId1Between(1, 1000);
        List<AwfulTable> answer = mapper.selectByExample(example);
        assertEquals(3, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : AwfulTableExample(mbg.test.mb3.generated.mixed.flat.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.mixed.flat.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.mixed.flat.model.AwfulTable) Test(org.junit.Test)

Example 37 with AwfulTableExample

use of mbg.test.mb3.generated.flat.model.AwfulTableExample in project generator by mybatis.

the class FlatJava5Test method testAwfulTableDeleteByExample.

@Test
public void testAwfulTableDeleteByExample() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
        AwfulTable record = new AwfulTable();
        record.seteMail("fred@fred.com");
        record.setEmailaddress("alsofred@fred.com");
        record.setFirstFirstName("fred1");
        record.setFrom("from field");
        record.setId1(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(7);
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("fred2@fred.com");
        record.setEmailaddress("alsofred2@fred.com");
        record.setFirstFirstName("fred11");
        record.setFrom("from from field");
        record.setId1(11);
        record.setId2(22);
        record.setId5(55);
        record.setId6(66);
        record.setId7(77);
        record.setSecondFirstName("fred22");
        record.setThirdFirstName("fred33");
        mapper.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        List<AwfulTable> answer = mapper.selectByExample(example);
        assertEquals(2, answer.size());
        example = new AwfulTableExample();
        example.createCriteria().andEMailLike("fred@%");
        int rows = mapper.deleteByExample(example);
        assertEquals(1, rows);
        example.clear();
        answer = mapper.selectByExample(example);
        assertEquals(1, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : AwfulTableExample(mbg.test.mb3.generated.mixed.flat.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.mixed.flat.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.mixed.flat.model.AwfulTable) Test(org.junit.Test)

Example 38 with AwfulTableExample

use of mbg.test.mb3.generated.flat.model.AwfulTableExample in project generator by mybatis.

the class ConditionalJava5Test method testAwfulTableSelectByExampleNoCriteria.

@Test
public void testAwfulTableSelectByExampleNoCriteria() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
        AwfulTable record = new AwfulTable();
        record.seteMail("fred@fred.com");
        record.setEmailaddress("alsofred@fred.com");
        record.setFirstFirstName("fred1");
        record.setFrom("from field");
        record.setId1(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(7);
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("wilma@wilma.com");
        record.setEmailaddress("alsoWilma@wilma.com");
        record.setFirstFirstName("wilma1");
        record.setFrom("from field");
        record.setId1(11);
        record.setId2(22);
        record.setId5(55);
        record.setId6(66);
        record.setId7(77);
        record.setSecondFirstName("wilma2");
        record.setThirdFirstName("wilma3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("pebbles@pebbles.com");
        record.setEmailaddress("alsoPebbles@pebbles.com");
        record.setFirstFirstName("pebbles1");
        record.setFrom("from field");
        record.setId1(111);
        record.setId2(222);
        record.setId5(555);
        record.setId6(666);
        record.setId7(777);
        record.setSecondFirstName("pebbles2");
        record.setThirdFirstName("pebbles3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("barney@barney.com");
        record.setEmailaddress("alsoBarney@barney.com");
        record.setFirstFirstName("barney1");
        record.setFrom("from field");
        record.setId1(1111);
        record.setId2(2222);
        record.setId5(5555);
        record.setId6(6666);
        record.setId7(7777);
        record.setSecondFirstName("barney2");
        record.setThirdFirstName("barney3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("betty@betty.com");
        record.setEmailaddress("alsoBetty@betty.com");
        record.setFirstFirstName("betty1");
        record.setFrom("from field");
        record.setId1(11111);
        record.setId2(22222);
        record.setId5(55555);
        record.setId6(66666);
        record.setId7(77777);
        record.setSecondFirstName("betty2");
        record.setThirdFirstName("betty3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("bammbamm@bammbamm.com");
        record.setEmailaddress("alsoBammbamm@bammbamm.com");
        record.setFirstFirstName("bammbamm1");
        record.setFrom("from field");
        record.setId1(111111);
        record.setId2(222222);
        record.setId5(555555);
        record.setId6(666666);
        record.setId7(777777);
        record.setSecondFirstName("bammbamm2");
        record.setThirdFirstName("bammbamm3");
        mapper.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria();
        example.setOrderByClause("\"A_CuStOmEr iD\" desc");
        List<AwfulTable> answer = mapper.selectByExample(example);
        assertEquals(6, answer.size());
        AwfulTable returnedRecord = answer.get(0);
        assertEquals(111111, returnedRecord.getId1().intValue());
        returnedRecord = answer.get(1);
        assertEquals(11111, returnedRecord.getId1().intValue());
        returnedRecord = answer.get(2);
        assertEquals(1111, returnedRecord.getId1().intValue());
        returnedRecord = answer.get(3);
        assertEquals(111, returnedRecord.getId1().intValue());
        returnedRecord = answer.get(4);
        assertEquals(11, returnedRecord.getId1().intValue());
        returnedRecord = answer.get(5);
        assertEquals(1, returnedRecord.getId1().intValue());
    } finally {
        sqlSession.close();
    }
}
Also used : AwfulTableExample(mbg.test.mb3.generated.mixed.conditional.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.mixed.conditional.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.mixed.conditional.model.AwfulTable) Test(org.junit.Test)

Example 39 with AwfulTableExample

use of mbg.test.mb3.generated.flat.model.AwfulTableExample in project generator by mybatis.

the class HierarchicalJava5Test method testAwfulTableDeleteByPrimaryKey.

@Test
public void testAwfulTableDeleteByPrimaryKey() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        AwfulTableMapper mapper = sqlSession.getMapper(AwfulTableMapper.class);
        AwfulTable record = new AwfulTable();
        record.seteMail("fred@fred.com");
        record.setEmailaddress("alsofred@fred.com");
        record.setFirstFirstName("fred1");
        record.setFrom("from field");
        record.setId1(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(7);
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        mapper.insert(record);
        Integer generatedCustomerId = record.getCustomerId();
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        int rows = mapper.deleteByPrimaryKey(key);
        assertEquals(1, rows);
        AwfulTableExample example = new AwfulTableExample();
        List<AwfulTable> answer = mapper.selectByExample(example);
        assertEquals(0, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : AwfulTableExample(mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.mixed.hierarchical.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTableKey) Test(org.junit.Test)

Example 40 with AwfulTableExample

use of mbg.test.mb3.generated.flat.model.AwfulTableExample in project generator by mybatis.

the class FlatJava2Test method testAwfulTableSelectByExampleLike.

public void testAwfulTableSelectByExampleLike() {
    AwfulTableDAO dao = getAwfulTableDAO();
    try {
        AwfulTable record = new AwfulTable();
        record.seteMail("fred@fred.com");
        record.setEmailaddress("alsofred@fred.com");
        record.setFirstFirstName("fred1");
        record.setFrom("from field");
        record.setId1(new Integer(1));
        record.setId2(new Integer(2));
        record.setId5(new Integer(5));
        record.setId6(new Integer(6));
        record.setId7(new Integer(7));
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        dao.insert(record);
        record = new AwfulTable();
        record.seteMail("wilma@wilma.com");
        record.setEmailaddress("alsoWilma@wilma.com");
        record.setFirstFirstName("wilma1");
        record.setFrom("from field");
        record.setId1(new Integer(11));
        record.setId2(new Integer(22));
        record.setId5(new Integer(55));
        record.setId6(new Integer(66));
        record.setId7(new Integer(77));
        record.setSecondFirstName("wilma2");
        record.setThirdFirstName("wilma3");
        dao.insert(record);
        record = new AwfulTable();
        record.seteMail("pebbles@pebbles.com");
        record.setEmailaddress("alsoPebbles@pebbles.com");
        record.setFirstFirstName("pebbles1");
        record.setFrom("from field");
        record.setId1(new Integer(111));
        record.setId2(new Integer(222));
        record.setId5(new Integer(555));
        record.setId6(new Integer(666));
        record.setId7(new Integer(777));
        record.setSecondFirstName("pebbles2");
        record.setThirdFirstName("pebbles3");
        dao.insert(record);
        record = new AwfulTable();
        record.seteMail("barney@barney.com");
        record.setEmailaddress("alsoBarney@barney.com");
        record.setFirstFirstName("barney1");
        record.setFrom("from field");
        record.setId1(new Integer(1111));
        record.setId2(new Integer(2222));
        record.setId5(new Integer(5555));
        record.setId6(new Integer(6666));
        record.setId7(new Integer(7777));
        record.setSecondFirstName("barney2");
        record.setThirdFirstName("barney3");
        dao.insert(record);
        record = new AwfulTable();
        record.seteMail("betty@betty.com");
        record.setEmailaddress("alsoBetty@betty.com");
        record.setFirstFirstName("betty1");
        record.setFrom("from field");
        record.setId1(new Integer(11111));
        record.setId2(new Integer(22222));
        record.setId5(new Integer(55555));
        record.setId6(new Integer(66666));
        record.setId7(new Integer(77777));
        record.setSecondFirstName("betty2");
        record.setThirdFirstName("betty3");
        dao.insert(record);
        record = new AwfulTable();
        record.seteMail("bammbamm@bammbamm.com");
        record.setEmailaddress("alsoBammbamm@bammbamm.com");
        record.setFirstFirstName("bammbamm1");
        record.setFrom("from field");
        record.setId1(new Integer(111111));
        record.setId2(new Integer(222222));
        record.setId5(new Integer(555555));
        record.setId6(new Integer(666666));
        record.setId7(new Integer(777777));
        record.setSecondFirstName("bammbamm2");
        record.setThirdFirstName("bammbamm3");
        dao.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria().andFirstFirstNameLike("b%");
        example.setOrderByClause("\"A_CuStOmEr iD\"");
        List answer = dao.selectByExample(example);
        assertEquals(3, answer.size());
        AwfulTable returnedRecord = (AwfulTable) answer.get(0);
        assertEquals(1111, returnedRecord.getId1().intValue());
        assertEquals(2222, returnedRecord.getId2().intValue());
        returnedRecord = (AwfulTable) answer.get(1);
        assertEquals(11111, returnedRecord.getId1().intValue());
        assertEquals(22222, returnedRecord.getId2().intValue());
        returnedRecord = (AwfulTable) answer.get(2);
        assertEquals(111111, returnedRecord.getId1().intValue());
        assertEquals(222222, returnedRecord.getId2().intValue());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j2.generated.flat.model.AwfulTableExample) SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j2.generated.flat.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j2.generated.flat.model.AwfulTable) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

Test (org.junit.Test)110 SqlSession (org.apache.ibatis.session.SqlSession)99 SQLException (java.sql.SQLException)22 ArrayList (java.util.ArrayList)18 AwfulTableDAO (mbg.test.ib2j2.generated.flat.dao.AwfulTableDAO)11 AwfulTable (mbg.test.ib2j2.generated.flat.model.AwfulTable)11 AwfulTableExample (mbg.test.ib2j2.generated.flat.model.AwfulTableExample)11 AwfulTableDAO (mbg.test.ib2j5.generated.flat.dao.AwfulTableDAO)11 AwfulTable (mbg.test.ib2j5.generated.flat.model.AwfulTable)11 AwfulTableExample (mbg.test.ib2j5.generated.flat.model.AwfulTableExample)11 AwfulTableMapper (mbg.test.mb3.generated.annotated.conditional.mapper.AwfulTableMapper)11 AwfulTable (mbg.test.mb3.generated.annotated.conditional.model.AwfulTable)11 AwfulTableExample (mbg.test.mb3.generated.annotated.conditional.model.AwfulTableExample)11 AwfulTableMapper (mbg.test.mb3.generated.annotated.flat.mapper.AwfulTableMapper)11 AwfulTable (mbg.test.mb3.generated.annotated.flat.model.AwfulTable)11 AwfulTableExample (mbg.test.mb3.generated.annotated.flat.model.AwfulTableExample)11 AwfulTableMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.AwfulTableMapper)11 AwfulTable (mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTable)11 AwfulTableExample (mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTableExample)11 AwfulTableMapper (mbg.test.mb3.generated.conditional.mapper.AwfulTableMapper)11