Search in sources :

Example 1 with Fieldsblobs

use of mbg.test.mb3.generated.mixed.conditional.model.Fieldsblobs 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)

Example 2 with Fieldsblobs

use of mbg.test.mb3.generated.mixed.conditional.model.Fieldsblobs in project generator by mybatis.

the class FlatJava5Test method testFieldsBlobsInsert.

@Test
public void testFieldsBlobsInsert() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        Fieldsblobs record = new Fieldsblobs();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        FieldsblobsExample example = new FieldsblobsExample();
        List<Fieldsblobs> answer = mapper.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        Fieldsblobs 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 : SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.flat.model.FieldsblobsExample) Fieldsblobs(mbg.test.mb3.generated.flat.model.Fieldsblobs) FieldsblobsMapper(mbg.test.mb3.generated.flat.mapper.FieldsblobsMapper) Test(org.junit.jupiter.api.Test)

Example 3 with Fieldsblobs

use of mbg.test.mb3.generated.mixed.conditional.model.Fieldsblobs in project generator by mybatis.

the class FlatJava5Test method testFieldsBlobsSelectByExampleWithBlobsNoCriteria.

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

Example 4 with Fieldsblobs

use of mbg.test.mb3.generated.mixed.conditional.model.Fieldsblobs 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("Jeff", "Smith", generateRandomBlob(), generateRandomBlob(), null);
        mapper.insert(record);
        record = new FieldsblobsWithBLOBs("Scott", "Jones", generateRandomBlob(), generateRandomBlob(), null);
        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.conditional.immutable.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.conditional.immutable.model.FieldsblobsExample) Fieldsblobs(mbg.test.mb3.generated.conditional.immutable.model.Fieldsblobs) FieldsblobsMapper(mbg.test.mb3.generated.conditional.immutable.mapper.FieldsblobsMapper) Test(org.junit.jupiter.api.Test)

Example 5 with Fieldsblobs

use of mbg.test.mb3.generated.mixed.conditional.model.Fieldsblobs in project generator by mybatis.

the class DynamicSqlTest method testFieldsBlobsSelectByExampleWithMultiInsert.

@Test
public void testFieldsBlobsSelectByExampleWithMultiInsert() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        Collection<Fieldsblobs> records = new ArrayList<>();
        Fieldsblobs record = new Fieldsblobs();
        record.setFirstname("Jeff");
        record.setLastname("Smith");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        records.add(record);
        record = new Fieldsblobs();
        record.setFirstname("Scott");
        record.setLastname("Jones");
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        records.add(record);
        int rowsInserted = mapper.insertMultiple(records);
        assertEquals(2, rowsInserted);
        List<Fieldsblobs> answer = mapper.select(dsl -> dsl.where(fieldsblobs.firstname, isLike("S%")));
        assertEquals(1, answer.size());
        Fieldsblobs 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()));
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Fieldsblobs(mbg.test.mb3.generated.dsql.model.Fieldsblobs) FieldsblobsMapper(mbg.test.mb3.generated.dsql.mapper.FieldsblobsMapper) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)60 Test (org.junit.jupiter.api.Test)60 FieldsblobsMapper (mbg.test.mb3.generated.annotated.flat.mapper.FieldsblobsMapper)8 Fieldsblobs (mbg.test.mb3.generated.annotated.flat.model.Fieldsblobs)8 FieldsblobsExample (mbg.test.mb3.generated.annotated.flat.model.FieldsblobsExample)8 FieldsblobsMapper (mbg.test.mb3.generated.flat.mapper.FieldsblobsMapper)8 Fieldsblobs (mbg.test.mb3.generated.flat.model.Fieldsblobs)8 FieldsblobsExample (mbg.test.mb3.generated.flat.model.FieldsblobsExample)8 FieldsblobsMapper (mbg.test.mb3.generated.mixed.flat.mapper.FieldsblobsMapper)8 Fieldsblobs (mbg.test.mb3.generated.mixed.flat.model.Fieldsblobs)8 FieldsblobsExample (mbg.test.mb3.generated.mixed.flat.model.FieldsblobsExample)8 FieldsblobsMapper (mbg.test.mb3.generated.dsql.mapper.FieldsblobsMapper)7 Fieldsblobs (mbg.test.mb3.generated.dsql.model.Fieldsblobs)7 FieldsblobsMapper (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Mapper.FieldsblobsMapper)3 Fieldsblobs (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.Fieldsblobs)3 FieldsblobsExample (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.FieldsblobsExample)3 FieldsblobsWithBLOBs (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.FieldsblobsWithBLOBs)3 FieldsblobsMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsblobsMapper)3 Fieldsblobs (mbg.test.mb3.generated.annotated.hierarchical.model.Fieldsblobs)3 FieldsblobsExample (mbg.test.mb3.generated.annotated.hierarchical.model.FieldsblobsExample)3