Search in sources :

Example 76 with AwfulTable

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

the class FlatJava5Test method testEquals5.

@Test
public void testEquals5() {
    AwfulTable awfulTable1 = new AwfulTable();
    awfulTable1.setActive(false);
    awfulTable1.setCustomerId(3);
    awfulTable1.seteMail("fred@fred.com");
    awfulTable1.setEmailaddress("fred@fred.com");
    awfulTable1.setFirstFirstName("Fred");
    awfulTable1.setFrom("from");
    awfulTable1.setId1(22);
    awfulTable1.setId2(33);
    awfulTable1.setId5(55);
    awfulTable1.setId6(66);
    awfulTable1.setId7(77);
    awfulTable1.setLastName("Rubble");
    awfulTable1.setSecondFirstName("Bamm Bamm");
    awfulTable1.setThirdFirstName("Pebbles");
    AwfulTable awfulTable2 = new AwfulTable();
    awfulTable2.setActive(false);
    awfulTable2.setCustomerId(3);
    awfulTable2.seteMail("fred@fred.com");
    awfulTable2.setEmailaddress("fred@fred.com");
    awfulTable2.setFirstFirstName("Fred");
    awfulTable2.setFrom("from");
    awfulTable2.setId1(22);
    awfulTable2.setId2(33);
    awfulTable2.setId5(55);
    awfulTable2.setId6(66);
    awfulTable2.setId7(77);
    awfulTable2.setLastName("Rubble");
    awfulTable2.setSecondFirstName("Bamm Bamm");
    awfulTable2.setThirdFirstName("Pebbles");
    assertTrue(awfulTable1.equals(awfulTable2));
    awfulTable2.setActive(true);
    assertFalse(awfulTable1.equals(awfulTable2));
}
Also used : AwfulTable(mbg.test.ib2j5.generated.flat.model.AwfulTable) Test(org.junit.Test)

Example 77 with AwfulTable

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

the class FlatJava5Test method testAwfulTableInsert.

@Test
public void testAwfulTableInsert() {
    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);
        assertEquals(57, generatedCustomerId.intValue());
        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 78 with AwfulTable

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

the class UpdateByExampleTest method testAwfulTableUpdateByExampleSelective.

@Test
public void testAwfulTableUpdateByExampleSelective() {
    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);
        AwfulTable newRecord = new AwfulTable();
        newRecord.setFirstFirstName("Alonzo");
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria().andEMailLike("fred2@%");
        int rows = mapper.updateByExampleSelective(newRecord, example);
        assertEquals(1, rows);
        List<AwfulTable> answer = mapper.selectByExample(example);
        assertEquals(1, answer.size());
        AwfulTable returnedRecord = answer.get(0);
        assertEquals(record.getCustomerId(), returnedRecord.getCustomerId());
        assertEquals(record.geteMail(), returnedRecord.geteMail());
        assertEquals(record.getEmailaddress(), returnedRecord.getEmailaddress());
        assertEquals(newRecord.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());
    } finally {
        sqlSession.close();
    }
}
Also used : AwfulTableExample(mbg.test.mb3.generated.flat.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.flat.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.flat.model.AwfulTable) Test(org.junit.Test)

Example 79 with AwfulTable

use of mbg.test.ib2j2.generated.flat.model.AwfulTable 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.flat.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.flat.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.flat.model.AwfulTable) Test(org.junit.Test)

Example 80 with AwfulTable

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

the class FlatJava5Test 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();
        int rows = mapper.deleteByPrimaryKey(generatedCustomerId);
        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.flat.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.flat.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.flat.model.AwfulTable) Test(org.junit.Test)

Aggregations

SQLException (java.sql.SQLException)48 Test (org.junit.Test)36 List (java.util.List)30 ArrayList (java.util.ArrayList)24 AwfulTable (mbg.test.ib2j5.generated.flat.model.AwfulTable)18 AwfulTable (mbg.test.mb3.generated.flat.model.AwfulTable)18 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.flat.dao.AwfulTableDAO)16 AwfulTableMapper (mbg.test.mb3.generated.flat.mapper.AwfulTableMapper)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.flat.model.AwfulTableExample)11 AwfulTableExample (mbg.test.mb3.generated.flat.model.AwfulTableExample)11