Search in sources :

Example 6 with AwfulTableKey

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

the class HierarchicalJava5Test method testAwfulTableUpdateByPrimaryKeySelective.

@Test
public void testAwfulTableUpdateByPrimaryKeySelective() {
    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();
        AwfulTable newRecord = new AwfulTable();
        newRecord.setCustomerId(generatedCustomerId);
        newRecord.setId1(11);
        newRecord.setId2(22);
        int rows = mapper.updateByPrimaryKeySelective(newRecord);
        assertEquals(1, rows);
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        AwfulTable returnedRecord = mapper.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(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());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.mixed.hierarchical.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTableKey) Test(org.junit.Test)

Example 7 with AwfulTableKey

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

Example 8 with AwfulTableKey

use of mbg.test.mb3.generated.annotated.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 9 with AwfulTableKey

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

the class HierarchicalJava5Test method testAwfulTableUpdateByPrimaryKey.

@Test
public void testAwfulTableUpdateByPrimaryKey() {
    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();
        record.setId1(11);
        record.setId2(22);
        int rows = mapper.updateByPrimaryKey(record);
        assertEquals(1, rows);
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        AwfulTable returnedRecord = mapper.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());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.annotated.hierarchical.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTableKey) Test(org.junit.Test)

Example 10 with AwfulTableKey

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

the class HierarchicalJava5Test method testAwfulTableUpdateByPrimaryKeySelective.

@Test
public void testAwfulTableUpdateByPrimaryKeySelective() {
    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();
        AwfulTable newRecord = new AwfulTable();
        newRecord.setCustomerId(generatedCustomerId);
        newRecord.setId1(11);
        newRecord.setId2(22);
        int rows = mapper.updateByPrimaryKeySelective(newRecord);
        assertEquals(1, rows);
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedCustomerId);
        AwfulTable returnedRecord = mapper.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(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());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.annotated.hierarchical.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTableKey) Test(org.junit.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)18 Test (org.junit.Test)18 AwfulTableMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.AwfulTableMapper)6 AwfulTable (mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTable)6 AwfulTableKey (mbg.test.mb3.generated.annotated.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 AwfulTableMapper (mbg.test.mb3.generated.mixed.hierarchical.mapper.AwfulTableMapper)6 AwfulTable (mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTable)6 AwfulTableKey (mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTableKey)6 AwfulTableExample (mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTableExample)1 AwfulTableExample (mbg.test.mb3.generated.hierarchical.model.AwfulTableExample)1 AwfulTableExample (mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTableExample)1