Search in sources :

Example 81 with PkblobsMapper

use of mbg.test.mb3.generated.dsql.mapper.PkblobsMapper in project generator by mybatis.

the class DynamicSqlTest method testPKBlobsSelectByExampleWithMultiInsert.

@Test
public void testPKBlobsSelectByExampleWithMultiInsert() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        Collection<Pkblobs> records = new ArrayList<>();
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        records.add(record);
        record = new Pkblobs();
        record.setId(6);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        records.add(record);
        int recordsInserted = mapper.insertMultiple(records);
        assertEquals(2, recordsInserted);
        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) ArrayList(java.util.ArrayList) PkblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.dsql.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 82 with PkblobsMapper

use of mbg.test.mb3.generated.dsql.mapper.PkblobsMapper in project generator by mybatis.

the class DynamicSqlTest method testPKBlobsSelectByPrimaryKey.

@Test
public void testPKBlobsSelectByPrimaryKey() {
    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 record1 = new Pkblobs();
        record1.setId(6);
        record1.setBlob1(generateRandomBlob());
        record1.setBlob2(generateRandomBlob());
        mapper.insert(record1);
        Optional<Pkblobs> newRecord = mapper.selectByPrimaryKey(6);
        assertThat(newRecord).hasValueSatisfying(nr -> {
            assertEquals(record1.getId(), nr.getId());
            assertTrue(blobsAreEqual(record1.getBlob1(), nr.getBlob1()));
            assertTrue(blobsAreEqual(record1.getBlob2(), nr.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 83 with PkblobsMapper

use of mbg.test.mb3.generated.dsql.mapper.PkblobsMapper in project generator by mybatis.

the class DynamicSqlTest method testPKBlobscount.

@Test
public void testPKBlobscount() {
    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);
        long rows = mapper.count(dsl -> dsl.where(pkblobs.id, isLessThan(4)));
        assertEquals(1, rows);
        rows = mapper.count(dsl -> dsl);
        assertEquals(2, rows);
    }
}
Also used : FieldsblobsDynamicSqlSupport.fieldsblobs(mbg.test.mb3.generated.dsql.mapper.FieldsblobsDynamicSqlSupport.fieldsblobs) FieldsonlyDynamicSqlSupport.fieldsonly(mbg.test.mb3.generated.dsql.mapper.FieldsonlyDynamicSqlSupport.fieldsonly) Arrays(java.util.Arrays) SqlBuilder(org.mybatis.dynamic.sql.SqlBuilder) Pkfieldsblobs(mbg.test.mb3.generated.dsql.model.Pkfieldsblobs) SelectDSLCompleter(org.mybatis.dynamic.sql.select.SelectDSLCompleter) TestUtilities.generateRandomBlob(mbg.test.common.util.TestUtilities.generateRandomBlob) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Pkonly(mbg.test.mb3.generated.dsql.model.Pkonly) LocalDateTime(java.time.LocalDateTime) PkonlyMapper(mbg.test.mb3.generated.dsql.mapper.PkonlyMapper) Pkblobs(mbg.test.mb3.generated.dsql.model.Pkblobs) TranslationMapper(mbg.test.mb3.generated.dsql.mapper.mbgtest.sub.TranslationMapper) CountDSLCompleter(org.mybatis.dynamic.sql.select.CountDSLCompleter) Fieldsblobs(mbg.test.mb3.generated.dsql.model.Fieldsblobs) PkonlyDynamicSqlSupport.pkonly(mbg.test.mb3.generated.dsql.mapper.PkonlyDynamicSqlSupport.pkonly) ArrayList(java.util.ArrayList) Id(mbg.test.mb3.generated.dsql.model.mbgtest.Id) BigDecimal(java.math.BigDecimal) AwfulTableDynamicSqlSupport.awfulTable(mbg.test.mb3.generated.dsql.mapper.AwfulTableDynamicSqlSupport.awfulTable) PkblobsDynamicSqlSupport.pkblobs(mbg.test.mb3.generated.dsql.mapper.PkblobsDynamicSqlSupport.pkblobs) LocalTime(java.time.LocalTime) PkfieldsblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkfieldsblobsMapper) SqlSession(org.apache.ibatis.session.SqlSession) PkfieldsMapper(mbg.test.mb3.generated.dsql.mapper.PkfieldsMapper) TestUtilities.blobsAreEqual(mbg.test.common.util.TestUtilities.blobsAreEqual) PkfieldsblobsDynamicSqlSupport.pkfieldsblobs(mbg.test.mb3.generated.dsql.mapper.PkfieldsblobsDynamicSqlSupport.pkfieldsblobs) Collection(java.util.Collection) AwfulTable(mbg.test.mb3.generated.dsql.model.AwfulTable) Assertions.within(org.assertj.core.api.Assertions.within) Fieldsonly(mbg.test.mb3.generated.dsql.model.Fieldsonly) Translation(mbg.test.mb3.generated.dsql.model.mbgtest.sub.Translation) IdMapper(mbg.test.mb3.generated.dsql.mapper.mbgtest.IdMapper) Test(org.junit.jupiter.api.Test) PkblobsMapper(mbg.test.mb3.generated.dsql.mapper.PkblobsMapper) List(java.util.List) AwfulTableMapper(mbg.test.mb3.generated.dsql.mapper.AwfulTableMapper) ChronoUnit(java.time.temporal.ChronoUnit) FieldsonlyMapper(mbg.test.mb3.generated.dsql.mapper.FieldsonlyMapper) Pkfields(mbg.test.mb3.generated.dsql.model.Pkfields) LocalDate(java.time.LocalDate) Assertions(org.junit.jupiter.api.Assertions) Optional(java.util.Optional) PkfieldsDynamicSqlSupport.pkfieldstable(mbg.test.mb3.generated.dsql.mapper.PkfieldsDynamicSqlSupport.pkfieldstable) FieldsblobsMapper(mbg.test.mb3.generated.dsql.mapper.FieldsblobsMapper) 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 84 with PkblobsMapper

use of mbg.test.mb3.generated.dsql.mapper.PkblobsMapper in project generator by mybatis.

the class ConditionalJava5Test method testPKBlobsDeleteByPrimaryKey.

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

Example 85 with PkblobsMapper

use of mbg.test.mb3.generated.dsql.mapper.PkblobsMapper in project generator by mybatis.

the class ConditionalJava5Test method testPKBlobsInsert.

@Test
public void testPKBlobsInsert() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        PkblobsExample example = new PkblobsExample();
        List<Pkblobs> answer = mapper.selectByExampleWithBLOBs(example);
        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()));
    } finally {
        sqlSession.close();
    }
}
Also used : PkblobsExample(mbg.test.mb3.generated.annotated.conditional.model.PkblobsExample) SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.annotated.conditional.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.annotated.conditional.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)182 Test (org.junit.jupiter.api.Test)182 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.annotated.hierarchical.Immutable.Mapper.PkblobsMapper)13 PkblobsWithBLOBs (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.PkblobsWithBLOBs)13 PkblobsMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.PkblobsMapper)13 PkblobsWithBLOBs (mbg.test.mb3.generated.annotated.hierarchical.model.PkblobsWithBLOBs)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.hierarchical.immutable.mapper.PkblobsMapper)13 PkblobsWithBLOBs (mbg.test.mb3.generated.hierarchical.immutable.model.PkblobsWithBLOBs)13 PkblobsMapper (mbg.test.mb3.generated.hierarchical.mapper.PkblobsMapper)13 PkblobsWithBLOBs (mbg.test.mb3.generated.hierarchical.model.PkblobsWithBLOBs)13 PkblobsMapper (mbg.test.mb3.generated.mixed.conditional.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.mixed.conditional.model.Pkblobs)13