Search in sources :

Example 1 with AwfulTableDAO

use of mbg.test.ib2j2.generated.conditional.dao.AwfulTableDAO in project generator by mybatis.

the class ConditionalJava5Test method testAwfulTableSelectByExampleComplexLike.

@Test
public void testAwfulTableSelectByExampleComplexLike() {
    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(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(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(11);
        record.setId2(22);
        record.setId5(55);
        record.setId6(66);
        record.setId7(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(111);
        record.setId2(222);
        record.setId5(555);
        record.setId6(666);
        record.setId7(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(1111);
        record.setId2(2222);
        record.setId5(5555);
        record.setId6(6666);
        record.setId7(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(11111);
        record.setId2(22222);
        record.setId5(55555);
        record.setId6(66666);
        record.setId7(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(111111);
        record.setId2(222222);
        record.setId5(555555);
        record.setId6(666666);
        record.setId7(777777);
        record.setSecondFirstName("bammbamm2");
        record.setThirdFirstName("bammbamm3");
        dao.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        example.or().andFirstFirstNameLike("b%").andId2EqualTo(222222);
        example.or().andFirstFirstNameLike("wi%");
        example.setOrderByClause("\"A_CuStOmEr iD\"");
        List<AwfulTable> answer = dao.selectByExample(example);
        assertEquals(2, answer.size());
        AwfulTable returnedRecord = answer.get(0);
        assertEquals(11, returnedRecord.getId1().intValue());
        assertEquals(22, returnedRecord.getId2().intValue());
        returnedRecord = answer.get(1);
        assertEquals(111111, returnedRecord.getId1().intValue());
        assertEquals(222222, returnedRecord.getId2().intValue());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j5.generated.conditional.model.AwfulTableExample) SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j5.generated.conditional.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.conditional.model.AwfulTable) Test(org.junit.Test)

Example 2 with AwfulTableDAO

use of mbg.test.ib2j2.generated.conditional.dao.AwfulTableDAO in project generator by mybatis.

the class ConditionalJava5Test method testAwfulTableCountByExample.

@Test
public void testAwfulTableCountByExample() {
    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(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(7);
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        dao.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");
        dao.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria().andEMailLike("fred@%");
        long rows = dao.countByExample(example);
        assertEquals(1, rows);
        example.clear();
        rows = dao.countByExample(example);
        assertEquals(2, rows);
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j5.generated.conditional.model.AwfulTableExample) SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j5.generated.conditional.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.conditional.model.AwfulTable) Test(org.junit.Test)

Example 3 with AwfulTableDAO

use of mbg.test.ib2j2.generated.conditional.dao.AwfulTableDAO in project generator by mybatis.

the class ConditionalJava5Test method testAwfulTableSelectByPrimaryKey.

@Test
public void testAwfulTableSelectByPrimaryKey() {
    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(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(7);
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        dao.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");
        Integer generatedKey = dao.insert(record);
        AwfulTable returnedRecord = dao.selectByPrimaryKey(generatedKey);
        assertNotNull(returnedRecord);
        assertEquals(record.getCustomerId(), returnedRecord.getCustomerId());
        assertEquals(record.geteMail(), returnedRecord.geteMail());
        assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
        assertEquals(record.getFirstFirstName(), returnedRecord.getFirstFirstName());
        assertEquals(record.getFrom(), returnedRecord.getFrom());
        assertEquals(record.getId1(), returnedRecord.getId1());
        assertEquals(record.getId2(), returnedRecord.getId2());
        assertEquals(record.getId5(), returnedRecord.getId5());
        assertEquals(record.getId6(), returnedRecord.getId6());
        assertEquals(record.getId7(), returnedRecord.getId7());
        assertEquals(record.getSecondFirstName(), returnedRecord.getSecondFirstName());
        assertEquals(record.getThirdFirstName(), returnedRecord.getThirdFirstName());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j5.generated.conditional.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.conditional.model.AwfulTable) Test(org.junit.Test)

Example 4 with AwfulTableDAO

use of mbg.test.ib2j2.generated.conditional.dao.AwfulTableDAO in project generator by mybatis.

the class ConditionalJava5Test method testAwfulTableUpdateByPrimaryKey.

@Test
public void testAwfulTableUpdateByPrimaryKey() {
    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(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(7);
        record.setSecondFirstName("fred2");
        record.setThirdFirstName("fred3");
        Integer generatedCustomerId = dao.insert(record);
        record.setId1(11);
        record.setId2(22);
        int rows = dao.updateByPrimaryKey(record);
        assertEquals(1, rows);
        AwfulTable returnedRecord = dao.selectByPrimaryKey(generatedCustomerId);
        assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
        assertEquals(record.geteMail(), returnedRecord.geteMail());
        assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
        assertEquals(record.getFirstFirstName(), returnedRecord.getFirstFirstName());
        assertEquals(record.getFrom(), returnedRecord.getFrom());
        assertEquals(record.getId1(), returnedRecord.getId1());
        assertEquals(record.getId2(), returnedRecord.getId2());
        assertEquals(record.getId5(), returnedRecord.getId5());
        assertEquals(record.getId6(), returnedRecord.getId6());
        assertEquals(record.getId7(), returnedRecord.getId7());
        assertEquals(record.getSecondFirstName(), returnedRecord.getSecondFirstName());
        assertEquals(record.getThirdFirstName(), returnedRecord.getThirdFirstName());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j5.generated.conditional.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.conditional.model.AwfulTable) Test(org.junit.Test)

Example 5 with AwfulTableDAO

use of mbg.test.ib2j2.generated.conditional.dao.AwfulTableDAO in project generator by mybatis.

the class ConditionalJava5Test method testAwfulTableSelectByExampleBetween.

@Test
public void testAwfulTableSelectByExampleBetween() {
    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(1);
        record.setId2(2);
        record.setId5(5);
        record.setId6(6);
        record.setId7(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(11);
        record.setId2(22);
        record.setId5(55);
        record.setId6(66);
        record.setId7(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(111);
        record.setId2(222);
        record.setId5(555);
        record.setId6(666);
        record.setId7(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(1111);
        record.setId2(2222);
        record.setId5(5555);
        record.setId6(6666);
        record.setId7(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(11111);
        record.setId2(22222);
        record.setId5(55555);
        record.setId6(66666);
        record.setId7(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(111111);
        record.setId2(222222);
        record.setId5(555555);
        record.setId6(666666);
        record.setId7(777777);
        record.setSecondFirstName("bammbamm2");
        record.setThirdFirstName("bammbamm3");
        dao.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria().andId1Between(1, 1000);
        List<AwfulTable> answer = dao.selectByExample(example);
        assertEquals(3, answer.size());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j5.generated.conditional.model.AwfulTableExample) SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j5.generated.conditional.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.conditional.model.AwfulTable) Test(org.junit.Test)

Aggregations

SQLException (java.sql.SQLException)48 List (java.util.List)30 ArrayList (java.util.ArrayList)23 AwfulTableDAO (mbg.test.ib2j2.generated.conditional.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j2.generated.conditional.model.AwfulTable)16 AwfulTableDAO (mbg.test.ib2j2.generated.flat.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j2.generated.flat.model.AwfulTable)16 AwfulTableDAO (mbg.test.ib2j2.generated.hierarchical.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j2.generated.hierarchical.model.AwfulTable)16 AwfulTableDAO (mbg.test.ib2j5.generated.conditional.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j5.generated.conditional.model.AwfulTable)16 Test (org.junit.Test)16 AwfulTableExample (mbg.test.ib2j2.generated.conditional.model.AwfulTableExample)11 AwfulTableExample (mbg.test.ib2j2.generated.flat.model.AwfulTableExample)11 AwfulTableExample (mbg.test.ib2j2.generated.hierarchical.model.AwfulTableExample)11 AwfulTableExample (mbg.test.ib2j5.generated.conditional.model.AwfulTableExample)11 AwfulTableKey (mbg.test.ib2j2.generated.hierarchical.model.AwfulTableKey)6 AwfulTableDAOImpl (mbg.test.ib2j2.generated.flat.dao.AwfulTableDAOImpl)1