Search in sources :

Example 16 with Pkblobs

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

the class ConditionalJava5Test method testPKBlobsSelectByExampleWithoutBlobsNoCriteria.

@Test
public void testPKBlobsSelectByExampleWithoutBlobsNoCriteria() {
    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);
        record = new Pkblobs();
        record.setId(6);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria();
        List<Pkblobs> answer = mapper.selectByExample(example);
        assertEquals(2, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : PkblobsExample(mbg.test.mb3.generated.conditional.model.PkblobsExample) SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.conditional.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.conditional.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 17 with Pkblobs

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

the class ConditionalJava5Test method testPKBlobsUpdateByPrimaryKeySelective.

@Test
public void testPKBlobsUpdateByPrimaryKeySelective() {
    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);
        Pkblobs newRecord = new Pkblobs();
        newRecord.setId(3);
        newRecord.setBlob2(generateRandomBlob());
        mapper.updateByPrimaryKeySelective(newRecord);
        Pkblobs returnedRecord = mapper.selectByPrimaryKey(3);
        assertNotNull(returnedRecord);
        assertEquals(record.getId(), returnedRecord.getId());
        assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
        assertTrue(blobsAreEqual(newRecord.getBlob2(), returnedRecord.getBlob2()));
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.conditional.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.conditional.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 18 with Pkblobs

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

the class ConditionalJava5Test method testPKBlobsCountByExample.

@Test
public void testPKBlobsCountByExample() {
    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);
        record = new Pkblobs();
        record.setId(6);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria().andIdLessThan(4);
        long rows = mapper.countByExample(example);
        assertEquals(1, rows);
        example.clear();
        rows = mapper.countByExample(example);
        assertEquals(2, rows);
    } finally {
        sqlSession.close();
    }
}
Also used : PkblobsExample(mbg.test.mb3.generated.conditional.model.PkblobsExample) SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.conditional.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.conditional.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 19 with Pkblobs

use of mbg.test.mb3.generated.dsql.model.Pkblobs 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.conditional.model.PkblobsExample) SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.conditional.mapper.PkblobsMapper) Pkblobs(mbg.test.mb3.generated.conditional.model.Pkblobs) Test(org.junit.jupiter.api.Test)

Example 20 with Pkblobs

use of mbg.test.mb3.generated.dsql.model.Pkblobs 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)

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