Search in sources :

Example 1 with PkblobsKey

use of mbg.test.mb3.generated.hierarchical.model.PkblobsKey in project generator by mybatis.

the class UpdateByExampleTest method testPKBlobsUpdateByExampleWithoutBLOBs.

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

Example 2 with PkblobsKey

use of mbg.test.mb3.generated.hierarchical.model.PkblobsKey in project generator by mybatis.

the class HierarchicalJava5Test method testPKBlobsSelectByExampleWithoutBlobsNoCriteria.

@Test
public void testPKBlobsSelectByExampleWithoutBlobsNoCriteria() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        PkblobsWithBLOBs record = new PkblobsWithBLOBs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        record = new PkblobsWithBLOBs();
        record.setId(6);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria();
        List<PkblobsKey> answer = mapper.selectByExample(example);
        assertEquals(2, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : PkblobsExample(mbg.test.mb3.generated.mixed.hierarchical.model.PkblobsExample) PkblobsWithBLOBs(mbg.test.mb3.generated.mixed.hierarchical.model.PkblobsWithBLOBs) PkblobsKey(mbg.test.mb3.generated.mixed.hierarchical.model.PkblobsKey) SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.mixed.hierarchical.mapper.PkblobsMapper) Test(org.junit.Test)

Example 3 with PkblobsKey

use of mbg.test.mb3.generated.hierarchical.model.PkblobsKey in project generator by mybatis.

the class HierarchicalJava2Test method testPKBlobsSelectByExampleWithoutBlobs.

public void testPKBlobsSelectByExampleWithoutBlobs() {
    PkblobsDAO dao = getPkblobsDAO();
    try {
        PkblobsWithBLOBs record = new PkblobsWithBLOBs();
        record.setId(new Integer(3));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        record = new PkblobsWithBLOBs();
        record.setId(new Integer(6));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria().andIdGreaterThan(new Integer(4));
        List answer = dao.selectByExampleWithoutBLOBs(example);
        assertEquals(1, answer.size());
        PkblobsKey key = (PkblobsKey) answer.get(0);
        assertFalse(key instanceof PkblobsWithBLOBs);
        assertEquals(6, key.getId().intValue());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.hierarchical.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample) PkblobsWithBLOBs(mbg.test.ib2j2.generated.hierarchical.model.PkblobsWithBLOBs) PkblobsKey(mbg.test.ib2j2.generated.hierarchical.model.PkblobsKey) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with PkblobsKey

use of mbg.test.mb3.generated.hierarchical.model.PkblobsKey in project generator by mybatis.

the class HierarchicalJava2Test method testPKBlobsDeleteByPrimaryKey.

public void testPKBlobsDeleteByPrimaryKey() {
    PkblobsDAO dao = getPkblobsDAO();
    try {
        PkblobsWithBLOBs record = new PkblobsWithBLOBs();
        record.setId(new Integer(3));
        record.setBlob1(TestUtilities.generateRandomBlob());
        record.setBlob2(TestUtilities.generateRandomBlob());
        dao.insert(record);
        PkblobsExample example = new PkblobsExample();
        List answer = dao.selectByExampleWithoutBLOBs(example);
        assertEquals(1, answer.size());
        PkblobsKey key = new PkblobsKey();
        key.setId(new Integer(3));
        int rows = dao.deleteByPrimaryKey(key);
        assertEquals(1, rows);
        example = new PkblobsExample();
        answer = dao.selectByExampleWithoutBLOBs(example);
        assertEquals(0, answer.size());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.hierarchical.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample) PkblobsWithBLOBs(mbg.test.ib2j2.generated.hierarchical.model.PkblobsWithBLOBs) PkblobsKey(mbg.test.ib2j2.generated.hierarchical.model.PkblobsKey) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with PkblobsKey

use of mbg.test.mb3.generated.hierarchical.model.PkblobsKey in project generator by mybatis.

the class HierarchicalJava5Test method testPKBlobsDeleteByPrimaryKey.

@Test
public void testPKBlobsDeleteByPrimaryKey() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        PkblobsMapper mapper = sqlSession.getMapper(PkblobsMapper.class);
        PkblobsWithBLOBs record = new PkblobsWithBLOBs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        mapper.insert(record);
        PkblobsExample example = new PkblobsExample();
        List<PkblobsKey> answer = mapper.selectByExample(example);
        assertEquals(1, answer.size());
        PkblobsKey key = new PkblobsKey();
        key.setId(3);
        int rows = mapper.deleteByPrimaryKey(key);
        assertEquals(1, rows);
        example = new PkblobsExample();
        answer = mapper.selectByExample(example);
        assertEquals(0, answer.size());
    } finally {
        sqlSession.close();
    }
}
Also used : PkblobsExample(mbg.test.mb3.generated.hierarchical.model.PkblobsExample) PkblobsWithBLOBs(mbg.test.mb3.generated.hierarchical.model.PkblobsWithBLOBs) PkblobsKey(mbg.test.mb3.generated.hierarchical.model.PkblobsKey) SqlSession(org.apache.ibatis.session.SqlSession) PkblobsMapper(mbg.test.mb3.generated.hierarchical.mapper.PkblobsMapper) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)56 SqlSession (org.apache.ibatis.session.SqlSession)48 PkblobsDAO (mbg.test.ib2j5.generated.hierarchical.dao.PkblobsDAO)8 PkblobsKey (mbg.test.ib2j5.generated.hierarchical.model.PkblobsKey)8 PkblobsWithBLOBs (mbg.test.ib2j5.generated.hierarchical.model.PkblobsWithBLOBs)8 PkblobsMapper (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Mapper.PkblobsMapper)8 PkblobsKey (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.PkblobsKey)8 PkblobsWithBLOBs (mbg.test.mb3.generated.annotated.hierarchical.Immutable.Model.PkblobsWithBLOBs)8 PkblobsMapper (mbg.test.mb3.generated.annotated.hierarchical.mapper.PkblobsMapper)8 PkblobsKey (mbg.test.mb3.generated.annotated.hierarchical.model.PkblobsKey)8 PkblobsWithBLOBs (mbg.test.mb3.generated.annotated.hierarchical.model.PkblobsWithBLOBs)8 PkblobsMapper (mbg.test.mb3.generated.hierarchical.immutable.mapper.PkblobsMapper)8 PkblobsKey (mbg.test.mb3.generated.hierarchical.immutable.model.PkblobsKey)8 PkblobsWithBLOBs (mbg.test.mb3.generated.hierarchical.immutable.model.PkblobsWithBLOBs)8 PkblobsMapper (mbg.test.mb3.generated.hierarchical.mapper.PkblobsMapper)8 PkblobsKey (mbg.test.mb3.generated.hierarchical.model.PkblobsKey)8 PkblobsWithBLOBs (mbg.test.mb3.generated.hierarchical.model.PkblobsWithBLOBs)8 PkblobsMapper (mbg.test.mb3.generated.mixed.hierarchical.Immutable.Mapper.PkblobsMapper)8 PkblobsKey (mbg.test.mb3.generated.mixed.hierarchical.Immutable.Model.PkblobsKey)8 PkblobsWithBLOBs (mbg.test.mb3.generated.mixed.hierarchical.Immutable.Model.PkblobsWithBLOBs)8