Search in sources :

Example 56 with AwfulTable

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

Example 57 with AwfulTable

use of mbg.test.mb3.generated.dsql.model.AwfulTable 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.hierarchical.mapper.AwfulTableMapper) AwfulTable(mbg.test.mb3.generated.hierarchical.model.AwfulTable) AwfulTableKey(mbg.test.mb3.generated.hierarchical.model.AwfulTableKey) Test(org.junit.jupiter.api.Test)

Example 58 with AwfulTable

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

the class HierarchicalJava5Test method testAwfulTableSelectByExampleBetween.

@Test
public void testAwfulTableSelectByExampleBetween() {
    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("wilma@wilma.com");
        record.setEmailaddress("alsoWilma@wilma.com");
        record.setFirstFirstName("wilma1");
        record.setFrom("from field");
        record.setId1(11);
        record.setId2(22);
        record.setId5(55);
        record.setId6(66);
        record.setId7(77);
        record.setSecondFirstName("wilma2");
        record.setThirdFirstName("wilma3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("pebbles@pebbles.com");
        record.setEmailaddress("alsoPebbles@pebbles.com");
        record.setFirstFirstName("pebbles1");
        record.setFrom("from field");
        record.setId1(111);
        record.setId2(222);
        record.setId5(555);
        record.setId6(666);
        record.setId7(777);
        record.setSecondFirstName("pebbles2");
        record.setThirdFirstName("pebbles3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("barney@barney.com");
        record.setEmailaddress("alsoBarney@barney.com");
        record.setFirstFirstName("barney1");
        record.setFrom("from field");
        record.setId1(1111);
        record.setId2(2222);
        record.setId5(5555);
        record.setId6(6666);
        record.setId7(7777);
        record.setSecondFirstName("barney2");
        record.setThirdFirstName("barney3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("betty@betty.com");
        record.setEmailaddress("alsoBetty@betty.com");
        record.setFirstFirstName("betty1");
        record.setFrom("from field");
        record.setId1(11111);
        record.setId2(22222);
        record.setId5(55555);
        record.setId6(66666);
        record.setId7(77777);
        record.setSecondFirstName("betty2");
        record.setThirdFirstName("betty3");
        mapper.insert(record);
        record = new AwfulTable();
        record.seteMail("bammbamm@bammbamm.com");
        record.setEmailaddress("alsoBammbamm@bammbamm.com");
        record.setFirstFirstName("bammbamm1");
        record.setFrom("from field");
        record.setId1(111111);
        record.setId2(222222);
        record.setId5(555555);
        record.setId6(666666);
        record.setId7(777777);
        record.setSecondFirstName("bammbamm2");
        record.setThirdFirstName("bammbamm3");
        mapper.insert(record);
        AwfulTableExample example = new AwfulTableExample();
        example.createCriteria().andId1Between(1, 1000);
        List<AwfulTable> answer = mapper.selectByExample(example);
        assertEquals(3, 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) Test(org.junit.jupiter.api.Test)

Example 59 with AwfulTable

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

the class HierarchicalJava5Test 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.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) Test(org.junit.jupiter.api.Test)

Example 60 with AwfulTable

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

the class HierarchicalJava5Test 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.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) 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