Search in sources :

Example 11 with PkblobsExample

use of mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample in project generator by mybatis.

the class FlatJava2Test method testPKBlobsSelectByExampleWithoutBlobsNoCriteria.

public void testPKBlobsSelectByExampleWithoutBlobsNoCriteria() {
    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);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria();
        List answer = dao.selectByExampleWithoutBLOBs(example);
        assertEquals(2, answer.size());
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.flat.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.flat.model.PkblobsExample) SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.flat.model.Pkblobs)

Example 12 with PkblobsExample

use of mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample 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)

Example 13 with PkblobsExample

use of mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample 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.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)

Example 14 with PkblobsExample

use of mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample in project generator by mybatis.

the class CountByExampleTest method testPKBlobsCountByExample.

public void testPKBlobsCountByExample() {
    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);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria().andIdLessThan(new Integer(4));
        long rows = dao.countByExample(example);
        assertEquals(1, rows);
        example.clear();
        rows = dao.countByExample(example);
        assertEquals(2, rows);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j2.generated.conditional.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.conditional.model.PkblobsExample) Pkblobs(mbg.test.ib2j2.generated.conditional.model.Pkblobs)

Example 15 with PkblobsExample

use of mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample in project generator by mybatis.

the class SelectByExampleTest method testPKBlobsSelectByExampleWithBlobs.

public void testPKBlobsSelectByExampleWithBlobs() {
    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);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria().andIdGreaterThan(new Integer(4));
        List answer = dao.selectByExampleWithBLOBs(example);
        assertEquals(1, answer.size());
        Pkblobs newRecord = (Pkblobs) answer.get(0);
        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) PkblobsExample(mbg.test.ib2j2.generated.conditional.model.PkblobsExample) ArrayList(java.util.ArrayList) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.conditional.model.Pkblobs)

Aggregations

List (java.util.List)27 SQLException (java.sql.SQLException)20 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)15 PkblobsDAO (mbg.test.ib2j2.generated.conditional.dao.PkblobsDAO)10 Pkblobs (mbg.test.ib2j2.generated.conditional.model.Pkblobs)10 PkblobsExample (mbg.test.ib2j2.generated.conditional.model.PkblobsExample)10 PkblobsDAO (mbg.test.ib2j2.generated.flat.dao.PkblobsDAO)10 Pkblobs (mbg.test.ib2j2.generated.flat.model.Pkblobs)10 PkblobsExample (mbg.test.ib2j2.generated.flat.model.PkblobsExample)10 PkblobsDAO (mbg.test.ib2j2.generated.hierarchical.dao.PkblobsDAO)10 PkblobsExample (mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample)10 PkblobsWithBLOBs (mbg.test.ib2j2.generated.hierarchical.model.PkblobsWithBLOBs)10 PkblobsDAO (mbg.test.ib2j5.generated.hierarchical.dao.PkblobsDAO)10 PkblobsExample (mbg.test.ib2j5.generated.hierarchical.model.PkblobsExample)10 PkblobsWithBLOBs (mbg.test.ib2j5.generated.hierarchical.model.PkblobsWithBLOBs)10 PkblobsMapper (mbg.test.mb3.generated.hierarchical.mapper.PkblobsMapper)10 PkblobsExample (mbg.test.mb3.generated.hierarchical.model.PkblobsExample)10 PkblobsWithBLOBs (mbg.test.mb3.generated.hierarchical.model.PkblobsWithBLOBs)10 SqlSession (org.apache.ibatis.session.SqlSession)10