Search in sources :

Example 1 with FieldsblobsWithBLOBs

use of mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsWithBLOBs in project generator by mybatis.

the class ConditionalJava5Test method testFieldsBlobsInsert.

@Test
public void testFieldsBlobsInsert() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new FieldsblobsWithBLOBs();
        record.setFirstname("Bob");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        FieldsblobsExample example = new FieldsblobsExample();
        example.createCriteria().andFirstnameEqualTo("Bob");
        List<FieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        FieldsblobsWithBLOBs returnedRecord = answer.get(0);
        assertEquals(record.getFirstname(), returnedRecord.getFirstname());
        assertEquals(record.getLastname(), returnedRecord.getLastname());
        assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
        assertTrue(blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsblobsWithBLOBs(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsExample) FieldsblobsMapper(mbg.test.mb3.generated.annotated.conditional.mapper.FieldsblobsMapper) Test(org.junit.jupiter.api.Test)

Example 2 with FieldsblobsWithBLOBs

use of mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsWithBLOBs in project generator by mybatis.

the class ConditionalJava5Test method testFieldsBlobsSelectByExampleWithBlobsNoCriteria.

@Test
public void testFieldsBlobsSelectByExampleWithBlobsNoCriteria() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new FieldsblobsWithBLOBs();
        record.setFirstname("Scott");
        record.setLastname("Jones");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        FieldsblobsExample example = new FieldsblobsExample();
        example.createCriteria();
        List<FieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
        assertEquals(2, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsblobsWithBLOBs(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsExample) FieldsblobsMapper(mbg.test.mb3.generated.annotated.conditional.mapper.FieldsblobsMapper) Test(org.junit.jupiter.api.Test)

Example 3 with FieldsblobsWithBLOBs

use of mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsWithBLOBs in project generator by mybatis.

the class ConditionalJava5Test method testFieldsBlobsSelectByExampleWithBlobs.

@Test
public void testFieldsBlobsSelectByExampleWithBlobs() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new FieldsblobsWithBLOBs();
        record.setFirstname("Scott");
        record.setLastname("Jones");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        FieldsblobsExample example = new FieldsblobsExample();
        example.createCriteria().andFirstnameLike("S%");
        List<FieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        FieldsblobsWithBLOBs newRecord = answer.get(0);
        assertEquals(record.getFirstname(), newRecord.getFirstname());
        assertEquals(record.getLastname(), newRecord.getLastname());
        assertTrue(blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
        assertTrue(blobsAreEqual(record.getBlob2(), newRecord.getBlob2()));
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsblobsWithBLOBs(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsExample) FieldsblobsMapper(mbg.test.mb3.generated.annotated.conditional.mapper.FieldsblobsMapper) Test(org.junit.jupiter.api.Test)

Example 4 with FieldsblobsWithBLOBs

use of mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsWithBLOBs in project generator by mybatis.

the class ConditionalJava5Test method testFieldsBlobsCountByExample.

@Test
public void testFieldsBlobsCountByExample() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new FieldsblobsWithBLOBs();
        record.setFirstname("Scott");
        record.setLastname("Jones");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        FieldsblobsExample example = new FieldsblobsExample();
        example.createCriteria().andFirstnameLike("S%");
        long rows = mapper.countByExample(example);
        assertEquals(1, rows);
        example.clear();
        rows = mapper.countByExample(example);
        assertEquals(2, rows);
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsblobsWithBLOBs(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsExample) FieldsblobsMapper(mbg.test.mb3.generated.annotated.conditional.mapper.FieldsblobsMapper) Test(org.junit.jupiter.api.Test)

Example 5 with FieldsblobsWithBLOBs

use of mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsWithBLOBs in project generator by mybatis.

the class ConditionalJava5Test method testFieldsBlobsDeleteByExample.

@Test
public void testFieldsBlobsDeleteByExample() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new FieldsblobsWithBLOBs();
        record.setFirstname("Scott");
        record.setLastname("Jones");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        FieldsblobsExample example = new FieldsblobsExample();
        List<Fieldsblobs> answer = mapper.selectByExample(example);
        assertEquals(2, answer.size());
        example = new FieldsblobsExample();
        example.createCriteria().andFirstnameLike("S%");
        int rows = mapper.deleteByExample(example);
        assertEquals(1, rows);
        example = new FieldsblobsExample();
        answer = mapper.selectByExample(example);
        assertEquals(1, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsblobsWithBLOBs(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsExample) Fieldsblobs(mbg.test.mb3.generated.annotated.conditional.model.Fieldsblobs) FieldsblobsMapper(mbg.test.mb3.generated.annotated.conditional.mapper.FieldsblobsMapper) Test(org.junit.jupiter.api.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)90 Test (org.junit.jupiter.api.Test)90 FieldsblobsMapper (mbg.test.mb3.generated.annotated.conditional.mapper.FieldsblobsMapper)9 FieldsblobsExample (mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsExample)9 FieldsblobsWithBLOBs (mbg.test.mb3.generated.annotated.conditional.model.FieldsblobsWithBLOBs)9 FieldsblobsMapper (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Mapper.FieldsblobsMapper)9 FieldsblobsExample (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.FieldsblobsExample)9 FieldsblobsWithBLOBs (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.FieldsblobsWithBLOBs)9 FieldsblobsMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsblobsMapper)9 FieldsblobsExample (mbg.test.mb3.generated.annotated.hierarchical.model.FieldsblobsExample)9 FieldsblobsWithBLOBs (mbg.test.mb3.generated.annotated.hierarchical.model.FieldsblobsWithBLOBs)9 FieldsblobsMapper (mbg.test.mb3.generated.conditional.immutable.mapper.FieldsblobsMapper)9 FieldsblobsExample (mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsExample)9 FieldsblobsWithBLOBs (mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsWithBLOBs)9 FieldsblobsMapper (mbg.test.mb3.generated.conditional.mapper.FieldsblobsMapper)9 FieldsblobsExample (mbg.test.mb3.generated.conditional.model.FieldsblobsExample)9 FieldsblobsWithBLOBs (mbg.test.mb3.generated.conditional.model.FieldsblobsWithBLOBs)9 FieldsblobsMapper (mbg.test.mb3.generated.hierarchical.immutable.mapper.FieldsblobsMapper)9 FieldsblobsExample (mbg.test.mb3.generated.hierarchical.immutable.model.FieldsblobsExample)9 FieldsblobsWithBLOBs (mbg.test.mb3.generated.hierarchical.immutable.model.FieldsblobsWithBLOBs)9