Search in sources :

Example 16 with AwfulTable

use of mbg.test.mb3.generated.annotated.conditional.model.AwfulTable in project generator by mybatis.

the class ConditionalJava5Test 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");
        int rows = mapper.insert(record);
        assertEquals(1, rows);
        Integer generatedCustomerId = record.getCustomerId();
        assertEquals(57, generatedCustomerId.intValue());
        record.setId1(11);
        record.setId2(22);
        rows = mapper.updateByPrimaryKey(record);
        assertEquals(1, rows);
        AwfulTable returnedRecord = mapper.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());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.annotated.conditional.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.annotated.conditional.model.AwfulTable) Test(org.junit.Test)

Example 17 with AwfulTable

use of mbg.test.mb3.generated.annotated.conditional.model.AwfulTable in project generator by mybatis.

the class ConditionalJava5Test 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.annotated.conditional.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.annotated.conditional.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.annotated.conditional.model.AwfulTable) Test(org.junit.Test)

Example 18 with AwfulTable

use of mbg.test.mb3.generated.annotated.conditional.model.AwfulTable in project generator by mybatis.

the class HierarchicalJava5Test method testAwfulTableSelectByPrimaryKey.

@Test
public void testAwfulTableSelectByPrimaryKey() {
    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);
        Integer generatedKey = record.getCustomerId();
        AwfulTableKey key = new AwfulTableKey();
        key.setCustomerId(generatedKey);
        AwfulTable returnedRecord = mapper.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());
    } 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 19 with AwfulTable

use of mbg.test.mb3.generated.annotated.conditional.model.AwfulTable in project generator by mybatis.

the class FlatJava5Test method testAwfulTableSelectByPrimaryKey.

@Test
public void testAwfulTableSelectByPrimaryKey() {
    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);
        Integer generatedKey = record.getCustomerId();
        AwfulTable returnedRecord = mapper.selectByPrimaryKey(generatedKey);
        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());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.annotated.flat.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.annotated.flat.model.AwfulTable) Test(org.junit.Test)

Example 20 with AwfulTable

use of mbg.test.mb3.generated.annotated.conditional.model.AwfulTable in project generator by mybatis.

the class FlatJava5Test method testAwfulTableCountByExample.

@Test
public void testAwfulTableCountByExample() {
    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();
        example.createCriteria().andEMailLike("fred@%");
        long rows = mapper.countByExample(example);
        assertEquals(1, rows);
        example.clear();
        rows = mapper.countByExample(example);
        assertEquals(2, rows);
    } finally {
        sqlSession.close();
    }
}
Also used : AwfulTableExample(mbg.test.mb3.generated.annotated.flat.model.AwfulTableExample) SqlSession(org.apache.ibatis.session.SqlSession) AwfulTableMapper(mbg.test.mb3.generated.annotated.flat.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.annotated.flat.model.AwfulTable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)152 SqlSession (org.apache.ibatis.session.SqlSession)146 AwfulTable (mbg.test.mb3.generated.annotated.flat.model.AwfulTable)18 AwfulTable (mbg.test.mb3.generated.flat.model.AwfulTable)18 AwfulTable (mbg.test.mb3.generated.mixed.flat.model.AwfulTable)18 AwfulTableMapper (mbg.test.mb3.generated.annotated.conditional.mapper.AwfulTableMapper)16 AwfulTable (mbg.test.mb3.generated.annotated.conditional.model.AwfulTable)16 AwfulTableMapper (mbg.test.mb3.generated.annotated.flat.mapper.AwfulTableMapper)16 AwfulTableMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.AwfulTableMapper)16 AwfulTable (mbg.test.mb3.generated.annotated.hierarchical.model.AwfulTable)16 AwfulTableMapper (mbg.test.mb3.generated.conditional.mapper.AwfulTableMapper)16 AwfulTable (mbg.test.mb3.generated.conditional.model.AwfulTable)16 AwfulTableMapper (mbg.test.mb3.generated.flat.mapper.AwfulTableMapper)16 AwfulTableMapper (mbg.test.mb3.generated.hierarchical.mapper.AwfulTableMapper)16 AwfulTable (mbg.test.mb3.generated.hierarchical.model.AwfulTable)16 AwfulTableMapper (mbg.test.mb3.generated.mixed.conditional.mapper.AwfulTableMapper)16 AwfulTable (mbg.test.mb3.generated.mixed.conditional.model.AwfulTable)16 AwfulTableMapper (mbg.test.mb3.generated.mixed.flat.mapper.AwfulTableMapper)16 AwfulTableMapper (mbg.test.mb3.generated.mixed.hierarchical.mapper.AwfulTableMapper)16 AwfulTable (mbg.test.mb3.generated.mixed.hierarchical.model.AwfulTable)16