Search in sources :

Example 81 with AwfulTable

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

Example 82 with AwfulTable

use of mbg.test.mb3.generated.mixed.flat.model.AwfulTable 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.jupiter.api.Test)

Example 83 with AwfulTable

use of mbg.test.mb3.generated.mixed.flat.model.AwfulTable 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.jupiter.api.Test)

Example 84 with AwfulTable

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

the class ConditionalJava5Test 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.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.jupiter.api.Test)

Example 85 with AwfulTable

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

the class ConditionalJava5Test 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");
        int rows = mapper.insert(record);
        assertEquals(1, rows);
        Integer generatedCustomerId = record.getCustomerId();
        assertEquals(57, generatedCustomerId.intValue());
        AwfulTable newRecord = new AwfulTable();
        newRecord.setCustomerId(generatedCustomerId);
        newRecord.setId1(11);
        newRecord.setId2(22);
        rows = mapper.updateByPrimaryKeySelective(newRecord);
        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(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.conditional.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.annotated.conditional.model.AwfulTable) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)171 SqlSession (org.apache.ibatis.session.SqlSession)163 AwfulTable (mbg.test.mb3.generated.dsql.model.AwfulTable)19 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.dsql.mapper.AwfulTableMapper)17 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