Search in sources :

Example 1 with AwfulTableKey

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

the class HierarchicalJava2Test method testAwfulTableInsert.

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(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);
        assertEquals(57, generatedCustomerId.intValue());
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        AwfulTable returnedRecord = dao.selectByPrimaryKey(key);
        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.ib2j2.generated.hierarchical.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j2.generated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.ib2j2.generated.hierarchical.model.AwfulTableKey)

Example 2 with AwfulTableKey

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

the class HierarchicalJava2Test method testAwfulTableInsertSelective.

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(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.insertSelective(record);
        assertEquals(57, generatedCustomerId.intValue());
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        AwfulTable returnedRecord = dao.selectByPrimaryKey(key);
        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.ib2j2.generated.hierarchical.dao.AwfulTableDAO) AwfulTable(mbg.test.ib2j2.generated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.ib2j2.generated.hierarchical.model.AwfulTableKey)

Example 3 with AwfulTableKey

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

Example 4 with AwfulTableKey

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

the class HierarchicalJava5Test 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());
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        AwfulTable returnedRecord = dao.selectByPrimaryKey(key);
        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 (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 5 with AwfulTableKey

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

the class HierarchicalJava5Test 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);
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        AwfulTable returnedRecord = dao.selectByPrimaryKey(key);
        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 (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)

Aggregations

Test (org.junit.Test)12 SQLException (java.sql.SQLException)6 AwfulTableDAO (mbg.test.ib2j2.generated.hierarchical.dao.AwfulTableDAO)6 AwfulTable (mbg.test.ib2j2.generated.hierarchical.model.AwfulTable)6 AwfulTableKey (mbg.test.ib2j2.generated.hierarchical.model.AwfulTableKey)6 AwfulTableDAO (mbg.test.ib2j5.generated.hierarchical.dao.AwfulTableDAO)6 AwfulTable (mbg.test.ib2j5.generated.hierarchical.model.AwfulTable)6 AwfulTableKey (mbg.test.ib2j5.generated.hierarchical.model.AwfulTableKey)6 AwfulTableMapper (mbg.test.mb3.generated.hierarchical.mapper.AwfulTableMapper)6 AwfulTable (mbg.test.mb3.generated.hierarchical.model.AwfulTable)6 AwfulTableKey (mbg.test.mb3.generated.hierarchical.model.AwfulTableKey)6 SqlSession (org.apache.ibatis.session.SqlSession)6 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AwfulTableExample (mbg.test.ib2j2.generated.hierarchical.model.AwfulTableExample)1 AwfulTableExample (mbg.test.ib2j5.generated.hierarchical.model.AwfulTableExample)1 AwfulTableExample (mbg.test.mb3.generated.hierarchical.model.AwfulTableExample)1