Search in sources :

Example 66 with AwfulTable

use of mbg.test.ib2j2.generated.hierarchical.model.AwfulTable in project generator by mybatis.

the class HierarchicalJava2Test method testAwfulTableDeleteByPrimaryKey.

public void testAwfulTableDeleteByPrimaryKey() {
    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");
        Integer generatedCustomerId = dao.insert(record);
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        int rows = dao.deleteByPrimaryKey(key);
        assertEquals(1, rows);
        AwfulTableExample example = new AwfulTableExample();
        List answer = dao.selectByExample(example);
        assertEquals(0, answer.size());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j2.generated.hierarchical.model.AwfulTableExample) SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j2.generated.hierarchical.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j2.generated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.ib2j2.generated.hierarchical.model.AwfulTableKey) ArrayList(java.util.ArrayList) List(java.util.List)

Example 67 with AwfulTable

use of mbg.test.ib2j2.generated.hierarchical.model.AwfulTable in project generator by mybatis.

the class HierarchicalJava5Test 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 (Exception e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j5.generated.hierarchical.model.AwfulTableExample) AwfulTableDAO(mbg.test.ib2j5.generated.hierarchical.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.hierarchical.model.AwfulTable) Test(org.junit.Test)

Example 68 with AwfulTable

use of mbg.test.ib2j2.generated.hierarchical.model.AwfulTable in project generator by mybatis.

the class HierarchicalJava5Test 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);
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedKey);
        AwfulTable returnedRecord = dao.selectByPrimaryKey(key);
        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 (Exception e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableDAO(mbg.test.ib2j5.generated.hierarchical.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.ib2j5.generated.hierarchical.model.AwfulTableKey) Test(org.junit.Test)

Example 69 with AwfulTable

use of mbg.test.ib2j2.generated.hierarchical.model.AwfulTable in project generator by mybatis.

the class UpdateByExampleTest method testAwfulTableUpdateByExample.

@Test
public void testAwfulTableUpdateByExample() {
    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);
        AwfulTable newRecord = new AwfulTable();
        newRecord.setFirstFirstName("Alonzo");
        newRecord.setCustomerId(58);
        newRecord.setId1(111);
        newRecord.setId2(222);
        newRecord.setId5(555);
        newRecord.setId6(666);
        newRecord.setId7(777);
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria().andEMailLike("fred2@%");
        int rows = dao.updateByExample(newRecord, example);
        assertEquals(1, rows);
        example.clear();
        example.createCriteria().andCustomerIdEqualTo(58);
        List<AwfulTable> answer = dao.selectByExample(example);
        assertEquals(1, answer.size());
        AwfulTable returnedRecord = answer.get(0);
        assertEquals(newRecord.getCustomerId(), returnedRecord.getCustomerId());
        assertNull(returnedRecord.geteMail());
        assertNull(returnedRecord.getEmailaddress());
        assertEquals(newRecord.getFirstFirstName(), returnedRecord.getFirstFirstName());
        assertNull(returnedRecord.getFrom());
        assertEquals(newRecord.getId1(), returnedRecord.getId1());
        assertEquals(newRecord.getId2(), returnedRecord.getId2());
        assertEquals(newRecord.getId5(), returnedRecord.getId5());
        assertEquals(newRecord.getId6(), returnedRecord.getId6());
        assertEquals(newRecord.getId7(), returnedRecord.getId7());
        assertNull(returnedRecord.getSecondFirstName());
        assertNull(returnedRecord.getThirdFirstName());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j5.generated.hierarchical.model.AwfulTableExample) AwfulTableDAO(mbg.test.ib2j5.generated.hierarchical.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.hierarchical.model.AwfulTable) Test(org.junit.Test)

Example 70 with AwfulTable

use of mbg.test.ib2j2.generated.hierarchical.model.AwfulTable in project generator by mybatis.

the class HierarchicalJava5Test method testAwfulTableDeleteByPrimaryKey.

@Test
public void testAwfulTableDeleteByPrimaryKey() {
    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);
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        int rows = dao.deleteByPrimaryKey(key);
        assertEquals(1, rows);
        AwfulTableExample example = new AwfulTableExample();
        List<AwfulTable> answer = dao.selectByExample(example);
        assertEquals(0, answer.size());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j5.generated.hierarchical.model.AwfulTableExample) AwfulTableDAO(mbg.test.ib2j5.generated.hierarchical.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.ib2j5.generated.hierarchical.model.AwfulTableKey) Test(org.junit.Test)

Aggregations

SQLException (java.sql.SQLException)32 Test (org.junit.Test)32 List (java.util.List)30 ArrayList (java.util.ArrayList)24 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.hierarchical.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j5.generated.hierarchical.model.AwfulTable)16 AwfulTableMapper (mbg.test.mb3.generated.hierarchical.mapper.AwfulTableMapper)16 AwfulTable (mbg.test.mb3.generated.hierarchical.model.AwfulTable)16 SqlSession (org.apache.ibatis.session.SqlSession)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.hierarchical.model.AwfulTableExample)11 AwfulTableExample (mbg.test.mb3.generated.hierarchical.model.AwfulTableExample)11