Search in sources :

Example 26 with FieldsblobsMapper

use of mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsblobsMapper in project generator by mybatis.

the class UpdateByExampleTest method testFieldsBlobsUpdateByExampleWithBLOBs.

@Test
public void testFieldsBlobsUpdateByExampleWithBLOBs() {
    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);
        FieldsblobsWithBLOBs newRecord = new FieldsblobsWithBLOBs();
        newRecord.setFirstname("Scott");
        newRecord.setLastname("Doe");
        FieldsblobsExample example = new FieldsblobsExample();
        example.createCriteria().andFirstnameLike("S%");
        int rows = mapper.updateByExampleWithBLOBs(newRecord, example);
        assertEquals(1, rows);
        List<FieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        FieldsblobsWithBLOBs returnedRecord = answer.get(0);
        assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
        assertEquals(newRecord.getLastname(), returnedRecord.getLastname());
        assertNull(returnedRecord.getBlob1());
        assertNull(returnedRecord.getBlob2());
    } finally {
        sqlSession.close();
    }
}
Also used : FieldsblobsWithBLOBs(mbg.test.mb3.generated.mixed.hierarchical.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.mixed.hierarchical.model.FieldsblobsExample) FieldsblobsMapper(mbg.test.mb3.generated.mixed.hierarchical.mapper.FieldsblobsMapper) Test(org.junit.Test)

Example 27 with FieldsblobsMapper

use of mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsblobsMapper in project generator by mybatis.

the class UpdateByExampleTest method testFieldsBlobsUpdateByExampleWithoutBLOBs.

@Test
public void testFieldsBlobsUpdateByExampleWithoutBLOBs() {
    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);
        Fieldsblobs newRecord = new Fieldsblobs();
        newRecord.setFirstname("Scott");
        newRecord.setLastname("Doe");
        FieldsblobsExample example = new FieldsblobsExample();
        example.createCriteria().andFirstnameLike("S%");
        int rows = mapper.updateByExample(newRecord, example);
        assertEquals(1, rows);
        List<FieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        FieldsblobsWithBLOBs returnedRecord = answer.get(0);
        assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
        assertEquals(newRecord.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.mixed.hierarchical.model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.mixed.hierarchical.model.FieldsblobsExample) Fieldsblobs(mbg.test.mb3.generated.mixed.hierarchical.model.Fieldsblobs) FieldsblobsMapper(mbg.test.mb3.generated.mixed.hierarchical.mapper.FieldsblobsMapper) Test(org.junit.Test)

Example 28 with FieldsblobsMapper

use of mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsblobsMapper in project generator by mybatis.

the class UpdateByExampleTest method testFieldsBlobsUpdateByExampleSelective.

@Test
public void testFieldsBlobsUpdateByExampleSelective() {
    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);
        FieldsblobsWithBLOBs newRecord = new FieldsblobsWithBLOBs(null, "Doe", null, null, null);
        FieldsblobsExample example = new FieldsblobsExample();
        example.createCriteria().andFirstnameLike("S%");
        int rows = mapper.updateByExampleSelective(newRecord, example);
        assertEquals(1, rows);
        List<FieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        FieldsblobsWithBLOBs returnedRecord = answer.get(0);
        assertEquals(record.getFirstname(), returnedRecord.getFirstname());
        assertEquals(newRecord.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.mixed.hierarchical.Immutable.Model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.mixed.hierarchical.Immutable.Model.FieldsblobsExample) FieldsblobsMapper(mbg.test.mb3.generated.mixed.hierarchical.Immutable.Mapper.FieldsblobsMapper) Test(org.junit.Test)

Example 29 with FieldsblobsMapper

use of mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsblobsMapper in project generator by mybatis.

the class SimpleAnnotatedTest method testFieldsblobs.

@Test
public void testFieldsblobs() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        FieldsblobsMapper mapper = sqlSession.getMapper(FieldsblobsMapper.class);
        Fieldsblobs record = new Fieldsblobs();
        record.setFirstname("Fred");
        record.setBlob1(TestUtilities.generateRandomBlob());
        mapper.insert(record);
        record = new Fieldsblobs();
        record.setFirstname("Barney");
        record.setBlob1(TestUtilities.generateRandomBlob());
        mapper.insert(record);
        List<Fieldsblobs> records = mapper.selectAll();
        assertEquals(2, records.size());
    } finally {
        sqlSession.close();
    }
}
Also used : SqlSession(org.apache.ibatis.session.SqlSession) Fieldsblobs(mbg.test.mb3.generated.simpleannotated.model.Fieldsblobs) FieldsblobsMapper(mbg.test.mb3.generated.simpleannotated.mapper.FieldsblobsMapper) Test(org.junit.Test)

Example 30 with FieldsblobsMapper

use of mbg.test.mb3.generated.annotated.hierarchical.mapper.FieldsblobsMapper in project generator by mybatis.

the class HierarchicalJava5Test method testFieldsBlobsSelectByExampleWithBlobs.

@Test
public void testFieldsBlobsSelectByExampleWithBlobs() {
    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();
        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.mixed.hierarchical.Immutable.Model.FieldsblobsWithBLOBs) SqlSession(org.apache.ibatis.session.SqlSession) FieldsblobsExample(mbg.test.mb3.generated.mixed.hierarchical.Immutable.Model.FieldsblobsExample) FieldsblobsMapper(mbg.test.mb3.generated.mixed.hierarchical.Immutable.Mapper.FieldsblobsMapper) Test(org.junit.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)107 Test (org.junit.Test)107 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.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 FieldsblobsMapper (mbg.test.mb3.generated.hierarchical.mapper.FieldsblobsMapper)9 FieldsblobsExample (mbg.test.mb3.generated.hierarchical.model.FieldsblobsExample)9 FieldsblobsWithBLOBs (mbg.test.mb3.generated.hierarchical.model.FieldsblobsWithBLOBs)9