Search in sources :

Example 26 with Pkblobs

use of mbg.test.ib2j2.generated.conditional.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.Test)

Example 27 with Pkblobs

use of mbg.test.ib2j2.generated.conditional.model.Pkblobs in project generator by mybatis.

the class InsertTest method testPKBlobsInsert.

public void testPKBlobsInsert() {
    PkblobsDAO dao = getPkblobsDAO();
    try {
        Pkblobs record = new Pkblobs();
        record.setId(new Integer(3));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        PkblobsExample example = new PkblobsExample();
        List answer = dao.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        Pkblobs returnedRecord = (Pkblobs) answer.get(0);
        assertEquals(record.getId(), returnedRecord.getId());
        assertTrue(TestUtilities.blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
        assertTrue(TestUtilities.blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.conditional.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.conditional.model.PkblobsExample) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.conditional.model.Pkblobs)

Example 28 with Pkblobs

use of mbg.test.ib2j2.generated.conditional.model.Pkblobs in project generator by mybatis.

the class SelectByPrimaryKeyTest method testPKBlobsSelectByPrimaryKey.

public void testPKBlobsSelectByPrimaryKey() {
    PkblobsDAO dao = getPkblobsDAO();
    try {
        Pkblobs record = new Pkblobs();
        record.setId(new Integer(3));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        record = new Pkblobs();
        record.setId(new Integer(6));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        Pkblobs newRecord = dao.selectByPrimaryKey(new Integer(6));
        assertNotNull(newRecord);
        assertEquals(record.getId(), newRecord.getId());
        assertTrue(TestUtilities.blobsAreEqual(record.getBlob1(), newRecord.getBlob1()));
        assertTrue(TestUtilities.blobsAreEqual(record.getBlob2(), newRecord.getBlob2()));
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.conditional.dao.PkblobsDAO) Pkblobs(mbg.test.ib2j2.generated.conditional.model.Pkblobs)

Example 29 with Pkblobs

use of mbg.test.ib2j2.generated.conditional.model.Pkblobs in project generator by mybatis.

the class UpdateByExampleTest method testPKBlobsUpdateByExampleSelective.

public void testPKBlobsUpdateByExampleSelective() {
    PkblobsDAO dao = getPkblobsDAO();
    try {
        Pkblobs record = new Pkblobs();
        record.setId(new Integer(3));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        record = new Pkblobs();
        record.setId(new Integer(6));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        Pkblobs newRecord = new Pkblobs();
        newRecord.setBlob1(TestUtilities.generateRandomBlob());
        PkblobsExample example = new PkblobsExample();
        example.createCriteria().andIdGreaterThan(new Integer(4));
        int rows = dao.updateByExampleSelective(newRecord, example);
        assertEquals(1, rows);
        List answer = dao.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        Pkblobs returnedRecord = (Pkblobs) answer.get(0);
        assertEquals(new Integer(6), returnedRecord.getId());
        assertTrue(TestUtilities.blobsAreEqual(newRecord.getBlob1(), returnedRecord.getBlob1()));
        assertTrue(TestUtilities.blobsAreEqual(record.getBlob2(), returnedRecord.getBlob2()));
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.conditional.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.conditional.model.PkblobsExample) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.conditional.model.Pkblobs)

Example 30 with Pkblobs

use of mbg.test.ib2j2.generated.conditional.model.Pkblobs in project generator by mybatis.

the class UpdateByExampleTest method testPKBlobsUpdateByExampleWithBLOBs.

public void testPKBlobsUpdateByExampleWithBLOBs() {
    PkblobsDAO dao = getPkblobsDAO();
    try {
        Pkblobs record = new Pkblobs();
        record.setId(new Integer(3));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        record = new Pkblobs();
        record.setId(new Integer(6));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        Pkblobs newRecord = new Pkblobs();
        newRecord.setId(new Integer(8));
        PkblobsExample example = new PkblobsExample();
        example.createCriteria().andIdGreaterThan(new Integer(4));
        int rows = dao.updateByExampleWithBLOBs(newRecord, example);
        assertEquals(1, rows);
        List answer = dao.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        Pkblobs returnedRecord = (Pkblobs) answer.get(0);
        assertEquals(new Integer(8), returnedRecord.getId());
        assertNull(returnedRecord.getBlob1());
        assertNull(returnedRecord.getBlob2());
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.conditional.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.conditional.model.PkblobsExample) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.conditional.model.Pkblobs)

Aggregations

SQLException (java.sql.SQLException)26 Test (org.junit.Test)26 List (java.util.List)18 PkblobsDAO (mbg.test.ib2j2.generated.conditional.dao.PkblobsDAO)13 Pkblobs (mbg.test.ib2j2.generated.conditional.model.Pkblobs)13 PkblobsDAO (mbg.test.ib2j2.generated.flat.dao.PkblobsDAO)13 Pkblobs (mbg.test.ib2j2.generated.flat.model.Pkblobs)13 PkblobsDAO (mbg.test.ib2j5.generated.conditional.dao.PkblobsDAO)13 Pkblobs (mbg.test.ib2j5.generated.conditional.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.conditional.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.conditional.model.Pkblobs)13 SqlSession (org.apache.ibatis.session.SqlSession)13 PkblobsExample (mbg.test.ib2j2.generated.conditional.model.PkblobsExample)10 PkblobsExample (mbg.test.ib2j2.generated.flat.model.PkblobsExample)10 PkblobsExample (mbg.test.ib2j5.generated.conditional.model.PkblobsExample)10 PkblobsExample (mbg.test.mb3.generated.conditional.model.PkblobsExample)10 ArrayList (java.util.ArrayList)9