Search in sources :

Example 66 with Pkfields

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

the class HierarchicalJava5Test method testPKfieldsDeleteByPrimaryKey.

@Test
public void testPKfieldsDeleteByPrimaryKey() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setId1(1);
        record.setId2(2);
        mapper.insert(record);
        PkfieldsKey key = new PkfieldsKey();
        key.setId1(1);
        key.setId2(2);
        int rows = mapper.deleteByPrimaryKey(key);
        assertEquals(1, rows);
        PkfieldsExample example = new PkfieldsExample();
        List<Pkfields> answer = mapper.selectByExample(example);
        assertEquals(0, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.annotated.hierarchical.Immutable.Mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.Pkfields) PkfieldsKey(mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.PkfieldsKey) PkfieldsExample(mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.PkfieldsExample) Test(org.junit.jupiter.api.Test)

Example 67 with Pkfields

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

the class HierarchicalJava5Test method testPKFieldsSelectByExampleEscapedFields.

@Test
public void testPKFieldsSelectByExampleEscapedFields() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Fred");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(1);
        record.setWierdField(11);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Wilma");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(2);
        record.setWierdField(22);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Pebbles");
        record.setLastname("Flintstone");
        record.setId1(1);
        record.setId2(3);
        record.setWierdField(33);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Barney");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(1);
        record.setWierdField(44);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Betty");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(2);
        record.setWierdField(55);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Bamm Bamm");
        record.setLastname("Rubble");
        record.setId1(2);
        record.setId2(3);
        record.setWierdField(66);
        mapper.insert(record);
        List<Integer> values = new ArrayList<>();
        values.add(11);
        values.add(22);
        PkfieldsExample example = new PkfieldsExample();
        example.createCriteria().andWierdFieldLessThan(40).andWierdFieldIn(values);
        example.setOrderByClause("ID1, ID2");
        List<Pkfields> answer = mapper.selectByExample(example);
        assertEquals(2, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.annotated.hierarchical.Immutable.Mapper.PkfieldsMapper) ArrayList(java.util.ArrayList) Pkfields(mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.Pkfields) PkfieldsExample(mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.PkfieldsExample) Test(org.junit.jupiter.api.Test)

Example 68 with Pkfields

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

the class DynamicSqlTest method testPKFieldsInsert.

@Test
public void testPKFieldsInsert() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setDatefield(LocalDate.now());
        record.setDecimal100field(10L);
        record.setDecimal155field(new BigDecimal("15.12345"));
        record.setDecimal30field((short) 3);
        record.setDecimal60field(6);
        record.setFirstname("Jeff");
        record.setId1(1);
        record.setId2(2);
        record.setLastname("Butler");
        record.setTimefield(LocalTime.of(13, 2, 4));
        record.setTimestampfield(LocalDateTime.now());
        record.setStringboolean(true);
        mapper.insert(record);
        Optional<Pkfields> returnedRecord = mapper.selectByPrimaryKey(2, 1);
        assertThat(returnedRecord).hasValueSatisfying(rr -> {
            assertEquals(record.getDatefield(), rr.getDatefield());
            assertEquals(record.getDecimal100field(), rr.getDecimal100field());
            assertEquals(record.getDecimal155field(), rr.getDecimal155field());
            assertEquals(record.getDecimal30field(), rr.getDecimal30field());
            assertEquals(record.getDecimal60field(), rr.getDecimal60field());
            assertEquals(record.getFirstname(), rr.getFirstname());
            assertEquals(record.getId1(), rr.getId1());
            assertEquals(record.getId2(), rr.getId2());
            assertEquals(record.getLastname(), rr.getLastname());
            assertEquals(record.getTimefield(), rr.getTimefield());
            assertThat(record.getTimestampfield()).isCloseTo(rr.getTimestampfield(), within(1, ChronoUnit.MILLIS));
            assertEquals(record.isStringboolean(), rr.isStringboolean());
        });
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.dsql.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.dsql.model.Pkfields) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test)

Example 69 with Pkfields

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

the class DynamicSqlTest method testPKfieldsDeleteByPrimaryKey.

@Test
public void testPKfieldsDeleteByPrimaryKey() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setId1(1);
        record.setId2(2);
        mapper.insert(record);
        int rows = mapper.deleteByPrimaryKey(2, 1);
        assertEquals(1, rows);
        List<Pkfields> answer = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(0, answer.size());
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.dsql.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.dsql.model.Pkfields) Test(org.junit.jupiter.api.Test)

Example 70 with Pkfields

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

the class DynamicSqlTest method testEquals2.

@Test
public void testEquals2() {
    Pkfields pkfields1 = new Pkfields();
    Pkfields pkfields2 = new Pkfields();
    assertEquals(pkfields2, pkfields1);
}
Also used : Pkfields(mbg.test.mb3.generated.dsql.model.Pkfields) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)267 SqlSession (org.apache.ibatis.session.SqlSession)243 ArrayList (java.util.ArrayList)39 Pkfields (mbg.test.mb3.generated.annotated.flat.model.Pkfields)23 Pkfields (mbg.test.mb3.generated.dsql.model.Pkfields)23 Pkfields (mbg.test.mb3.generated.flat.model.Pkfields)23 Pkfields (mbg.test.mb3.generated.mixed.flat.model.Pkfields)23 PkfieldsMapper (mbg.test.mb3.generated.annotated.conditional.mapper.PkfieldsMapper)17 Pkfields (mbg.test.mb3.generated.annotated.conditional.model.Pkfields)17 PkfieldsMapper (mbg.test.mb3.generated.annotated.flat.mapper.PkfieldsMapper)17 PkfieldsMapper (mbg.test.mb3.generated.conditional.mapper.PkfieldsMapper)17 Pkfields (mbg.test.mb3.generated.conditional.model.Pkfields)17 PkfieldsMapper (mbg.test.mb3.generated.flat.mapper.PkfieldsMapper)17 PkfieldsMapper (mbg.test.mb3.generated.mixed.conditional.mapper.PkfieldsMapper)17 Pkfields (mbg.test.mb3.generated.mixed.conditional.model.Pkfields)17 PkfieldsMapper (mbg.test.mb3.generated.mixed.flat.mapper.PkfieldsMapper)17 SQLException (java.sql.SQLException)16 PkfieldsDAO (mbg.test.ib2j2.generated.hierarchical.dao.PkfieldsDAO)16 Pkfields (mbg.test.ib2j2.generated.hierarchical.model.Pkfields)16 PkfieldsDAO (mbg.test.ib2j5.generated.hierarchical.dao.PkfieldsDAO)16