Search in sources :

Example 76 with Pkblobs

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

the class DynamicSqlTest method testPKBlobsInsert.

@Test
public void testPKBlobsInsert() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        List<Pkblobs> answer = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(1, answer.size());
        Pkblobs returnedRecord = answer.get(0);
        assertEquals(record.getId(), returnedRecord.getId());
        assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
        assertTrue(blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.dsql.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 77 with Pkblobs

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

the class DynamicSqlTest method testPKBlobsUpdateByPrimaryKeySelective.

@Test
public void testPKBlobsUpdateByPrimaryKeySelective() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        Pkblobs newRecord = new Pkblobs();
        newRecord.setId(3);
        newRecord.setBlob2(generateRandomBlob());
        mapper.updateByPrimaryKeySelective(newRecord);
        Optional<Pkblobs> returnedRecord = mapper.selectByPrimaryKey(3);
        assertThat(returnedRecord).hasValueSatisfying(rr -> {
            assertEquals(record.getId(), rr.getId());
            assertTrue(blobsAreEqual(record.getBlob1(), rr.getBlob1()));
            assertTrue(blobsAreEqual(newRecord.getBlob2(), rr.getBlob2()));
        });
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.dsql.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 78 with Pkblobs

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

the class DynamicSqlTest method testPKBlobsDeleteByPrimaryKey.

@Test
public void testPKBlobsDeleteByPrimaryKey() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        List<Pkblobs> answer = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(1, answer.size());
        int rows = mapper.deleteByPrimaryKey(3);
        assertEquals(1, rows);
        answer = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(0, answer.size());
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.dsql.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 79 with Pkblobs

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

the class DynamicSqlTest method testPKBlobsSelectByExampleWithBlobs.

@Test
public void testPKBlobsSelectByExampleWithBlobs() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new Pkblobs();
        record.setId(6);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        List<Pkblobs> answer = mapper.select(DSL -> DSL.where(pkblobs.id, isGreaterThan(4)));
        assertEquals(1, answer.size());
        Pkblobs newRecord = answer.get(0);
        assertEquals(record.getId(), newRecord.getId());
        assertTrue(blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
        assertTrue(blobsAreEqual(record.getBlob2(), newRecord.getBlob2()));
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.dsql.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 80 with Pkblobs

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

the class DynamicSqlTest method testPKBlobsdelete.

@Test
public void testPKBlobsdelete() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new Pkblobs();
        record.setId(6);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        List<Pkblobs> answer = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(2, answer.size());
        int rows = mapper.delete(dsl -> dsl.where(pkblobs.id, isLessThan(4)));
        assertEquals(1, rows);
        answer = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(1, answer.size());
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.dsql.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)104 Test (org.junit.jupiter.api.Test)104 PkblobsMapper (mbg.test.mb3.generated.annotated.conditional.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.annotated.conditional.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.annotated.flat.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.annotated.flat.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.conditional.immutable.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.conditional.immutable.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.conditional.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.conditional.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.flat.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.flat.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.mixed.conditional.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.mixed.conditional.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.mixed.flat.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.mixed.flat.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.dsql.mapper.PkblobsMapper)11 Pkblobs (mbg.test.mb3.generated.dsql.model.Pkblobs)11 PkblobsExample (mbg.test.mb3.generated.annotated.conditional.model.PkblobsExample)10 PkblobsExample (mbg.test.mb3.generated.annotated.flat.model.PkblobsExample)10