Search in sources :

Example 76 with Pkfields

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

the class FlatJava5Test method testEquals3.

@Test
public void testEquals3() {
    Pkfields pkfields1 = new Pkfields();
    pkfields1.setId1(2);
    Pkfields pkfields2 = new Pkfields();
    pkfields2.setId1(2);
    assertTrue(pkfields1.equals(pkfields2));
}
Also used : Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) Test(org.junit.jupiter.api.Test)

Example 77 with Pkfields

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

the class FlatJava5Test method testPKFieldsInsert.

@Test
public void testPKFieldsInsert() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
        Pkfields record = new Pkfields();
        record.setDatefield(new Date());
        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(new Date());
        record.setTimestampfield(new Date());
        record.setStringboolean(true);
        mapper.insert(record);
        Pkfields returnedRecord = mapper.selectByPrimaryKey(2, 1);
        assertNotNull(returnedRecord);
        assertTrue(datesAreEqual(record.getDatefield(), returnedRecord.getDatefield()));
        assertEquals(record.getDecimal100field(), returnedRecord.getDecimal100field());
        assertEquals(record.getDecimal155field(), returnedRecord.getDecimal155field());
        assertEquals(record.getDecimal30field(), returnedRecord.getDecimal30field());
        assertEquals(record.getDecimal60field(), returnedRecord.getDecimal60field());
        assertEquals(record.getFirstname(), returnedRecord.getFirstname());
        assertEquals(record.getId1(), returnedRecord.getId1());
        assertEquals(record.getId2(), returnedRecord.getId2());
        assertEquals(record.getLastname(), returnedRecord.getLastname());
        assertTrue(timesAreEqual(record.getTimefield(), returnedRecord.getTimefield()));
        assertEquals(record.getTimestampfield(), returnedRecord.getTimestampfield());
        assertEquals(record.isStringboolean(), returnedRecord.isStringboolean());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.annotated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) Date(java.util.Date) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test)

Example 78 with Pkfields

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

the class FlatJava5Test method testPKFieldsSelectByPrimaryKey.

@Test
public void testPKFieldsSelectByPrimaryKey() {
    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);
        record = new Pkfields();
        record.setFirstname("Bob");
        record.setLastname("Jones");
        record.setId1(3);
        record.setId2(4);
        mapper.insert(record);
        Pkfields newRecord = mapper.selectByPrimaryKey(4, 3);
        assertNotNull(newRecord);
        assertEquals(record.getFirstname(), newRecord.getFirstname());
        assertEquals(record.getLastname(), newRecord.getLastname());
        assertEquals(record.getId1(), newRecord.getId1());
        assertEquals(record.getId2(), newRecord.getId2());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.annotated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) Test(org.junit.jupiter.api.Test)

Example 79 with Pkfields

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

the class UpdateByExampleTest method testPKFieldsUpdateByExampleSelective.

@Test
public void testPKFieldsUpdateByExampleSelective() {
    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);
        record = new Pkfields();
        record.setFirstname("Bob");
        record.setLastname("Jones");
        record.setId1(3);
        record.setId2(4);
        mapper.insert(record);
        record = new Pkfields();
        record.setFirstname("Fred");
        PkfieldsExample example = new PkfieldsExample();
        example.createCriteria().andLastnameLike("J%");
        int rows = mapper.updateByExampleSelective(record, example);
        assertEquals(1, rows);
        example.clear();
        example.createCriteria().andFirstnameEqualTo("Fred").andLastnameEqualTo("Jones").andId1EqualTo(3).andId2EqualTo(4);
        long returnedRows = mapper.countByExample(example);
        assertEquals(1, returnedRows);
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.annotated.flat.mapper.PkfieldsMapper) Pkfields(mbg.test.mb3.generated.annotated.flat.model.Pkfields) PkfieldsExample(mbg.test.mb3.generated.annotated.flat.model.PkfieldsExample) Test(org.junit.jupiter.api.Test)

Example 80 with Pkfields

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

the class UpdateByExampleTest method testPKFieldsUpdateByExample.

@Test
public void testPKFieldsUpdateByExample() {
    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);
        record = new Pkfields();
        record.setFirstname("Bob");
        record.setLastname("Jones");
        record.setId1(3);
        record.setId2(4);
        mapper.insert(record);
        Pkfields updateRecord = new Pkfields();
        updateRecord.setFirstname("Fred");
        updateRecord.setId1(3);
        updateRecord.setId2(4);
        int rows = mapper.update(dsl -> PkfieldsMapper.updateAllColumns(updateRecord, dsl).where(pkfieldstable.id1, isEqualTo(3)).and(pkfieldstable.id2, isEqualTo(4)));
        assertEquals(1, rows);
        long returnedRows = mapper.count(dsl -> dsl.where(pkfieldstable.firstname, isEqualTo("Fred")).and(pkfieldstable.id1, isEqualTo(3)).and(pkfieldstable.id2, isEqualTo(4)));
        assertEquals(1, returnedRows);
    }
}
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)

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