Search in sources :

Example 6 with AwfulTable

use of mbg.test.ib2j5.generated.flat.model.AwfulTable in project generator by mybatis.

the class ConditionalJava5Test method testAwfulTableDeleteByExample.

@Test
public void testAwfulTableDeleteByExample() {
    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();
        List<AwfulTable> answer = dao.selectByExample(example);
        assertEquals(2, answer.size());
        example = new AwfulTableExample();
        example.createCriteria().andEMailLike("fred@%");
        int rows = dao.deleteByExample(example);
        assertEquals(1, rows);
        example.clear();
        answer = dao.selectByExample(example);
        assertEquals(1, 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)

Example 7 with AwfulTable

use of mbg.test.ib2j5.generated.flat.model.AwfulTable in project generator by mybatis.

the class FlatJava5Test method testAwfulTableUpdateByPrimaryKeySelective.

@Test
public void testAwfulTableUpdateByPrimaryKeySelective() {
    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);
        AwfulTable newRecord = new AwfulTable();
        newRecord.setCustomerId(generatedCustomerId);
        newRecord.setId1(11);
        newRecord.setId2(22);
        int rows = dao.updateByPrimaryKeySelective(newRecord);
        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(newRecord.getId1(), returnedRecord.getId1());
        assertEquals(newRecord.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.flat.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.flat.model.AwfulTable) Test(org.junit.Test)

Example 8 with AwfulTable

use of mbg.test.ib2j5.generated.flat.model.AwfulTable in project generator by mybatis.

the class FlatJava5Test 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);
        int rows = dao.deleteByPrimaryKey(generatedCustomerId);
        assertEquals(1, rows);
        AwfulTableExample example = new AwfulTableExample();
        List<AwfulTable> answer = dao.selectByExample(example);
        assertEquals(0, answer.size());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : AwfulTableExample(mbg.test.ib2j5.generated.flat.model.AwfulTableExample) SQLException(java.sql.SQLException) AwfulTableDAO(mbg.test.ib2j5.generated.flat.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.flat.model.AwfulTable) Test(org.junit.Test)

Example 9 with AwfulTable

use of mbg.test.ib2j5.generated.flat.model.AwfulTable in project generator by mybatis.

the class FlatJava5Test 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.flat.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.flat.model.AwfulTable) Test(org.junit.Test)

Example 10 with AwfulTable

use of mbg.test.ib2j5.generated.flat.model.AwfulTable in project generator by mybatis.

the class FlatJava5Test method testAwfulTableInsertSelective.

@Test
public void testAwfulTableInsertSelective() {
    AwfulTableDAO dao = getAwfulTableDAO();
    try {
        AwfulTable record = new AwfulTable();
        record.seteMail("fred@fred.com");
        record.setEmailaddress("alsofred@fred.com");
        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.insertSelective(record);
        assertEquals(57, generatedCustomerId.intValue());
        AwfulTable returnedRecord = dao.selectByPrimaryKey(generatedCustomerId);
        assertEquals(generatedCustomerId, returnedRecord.getCustomerId());
        assertEquals(record.geteMail(), returnedRecord.geteMail());
        assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
        assertEquals("Mabel", 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.flat.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j5.generated.flat.model.AwfulTable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)68 SQLException (java.sql.SQLException)48 AwfulTable (mbg.test.ib2j5.generated.flat.model.AwfulTable)18 AwfulTable (mbg.test.mb3.generated.flat.model.AwfulTable)18 AwfulTableDAO (mbg.test.ib2j2.generated.flat.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j2.generated.flat.model.AwfulTable)16 AwfulTableDAO (mbg.test.ib2j5.generated.conditional.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j5.generated.conditional.model.AwfulTable)16 AwfulTableDAO (mbg.test.ib2j5.generated.flat.dao.AwfulTableDAO)16 AwfulTableDAO (mbg.test.ib2j5.generated.hierarchical.dao.AwfulTableDAO)16 AwfulTable (mbg.test.ib2j5.generated.hierarchical.model.AwfulTable)16 AwfulTableMapper (mbg.test.mb3.generated.flat.mapper.AwfulTableMapper)16 SqlSession (org.apache.ibatis.session.SqlSession)16 ArrayList (java.util.ArrayList)12 AwfulTableExample (mbg.test.ib2j2.generated.flat.model.AwfulTableExample)11 AwfulTableExample (mbg.test.ib2j5.generated.conditional.model.AwfulTableExample)11 AwfulTableExample (mbg.test.ib2j5.generated.flat.model.AwfulTableExample)11 AwfulTableExample (mbg.test.ib2j5.generated.hierarchical.model.AwfulTableExample)11 AwfulTableExample (mbg.test.mb3.generated.flat.model.AwfulTableExample)11 List (java.util.List)10