Search in sources :

Example 21 with Pkblobs

use of mbg.test.ib2j5.generated.flat.model.Pkblobs in project generator by mybatis.

the class FlatJava5Test method testPKBlobsCountByExample.

@Test
public void testPKBlobsCountByExample() {
    PkblobsDAO dao = getPkblobsDAO();
    try {
        Pkblobs record = new Pkblobs();
        record.setId(3);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        dao.insert(record);
        record = new Pkblobs();
        record.setId(6);
        record.setBlob1(generateRandomBlob());
        record.setBlob2(generateRandomBlob());
        dao.insert(record);
        PkblobsExample example = new PkblobsExample();
        example.createCriteria().andIdLessThan(4);
        long rows = dao.countByExample(example);
        assertEquals(1, rows);
        example.clear();
        rows = dao.countByExample(example);
        assertEquals(2, rows);
    } catch (SQLException e) {
        fail(e.getMessage());
    }
}
Also used : PkblobsDAO(mbg.test.ib2j5.generated.flat.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j5.generated.flat.model.PkblobsExample) SQLException(java.sql.SQLException) Pkblobs(mbg.test.ib2j5.generated.flat.model.Pkblobs) Test(org.junit.Test)

Example 22 with Pkblobs

use of mbg.test.ib2j5.generated.flat.model.Pkblobs in project generator by mybatis.

the class UpdateByExampleTest method testPKBlobsUpdateByExampleWithoutBLOBs.

public void testPKBlobsUpdateByExampleWithoutBLOBs() {
    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.updateByExampleWithoutBLOBs(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());
        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.flat.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.flat.model.PkblobsExample) SQLException(java.sql.SQLException) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.flat.model.Pkblobs)

Example 23 with Pkblobs

use of mbg.test.ib2j5.generated.flat.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 (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) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.flat.model.Pkblobs)

Example 24 with Pkblobs

use of mbg.test.ib2j5.generated.flat.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 (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) List(java.util.List) Pkblobs(mbg.test.ib2j2.generated.flat.model.Pkblobs)

Example 25 with Pkblobs

use of mbg.test.ib2j5.generated.flat.model.Pkblobs in project generator by mybatis.

the class FlatJava2Test method testPKBlobsDeleteByPrimaryKey.

public void testPKBlobsDeleteByPrimaryKey() {
    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.selectByExampleWithoutBLOBs(example);
        assertEquals(1, answer.size());
        int rows = dao.deleteByPrimaryKey(new Integer(3));
        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.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)

Aggregations

SQLException (java.sql.SQLException)39 Test (org.junit.Test)39 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 PkblobsDAO (mbg.test.ib2j5.generated.flat.dao.PkblobsDAO)13 Pkblobs (mbg.test.ib2j5.generated.flat.model.Pkblobs)13 PkblobsMapper (mbg.test.mb3.generated.flat.mapper.PkblobsMapper)13 Pkblobs (mbg.test.mb3.generated.flat.model.Pkblobs)13 SqlSession (org.apache.ibatis.session.SqlSession)13 PkblobsExample (mbg.test.ib2j2.generated.flat.model.PkblobsExample)10 PkblobsExample (mbg.test.ib2j5.generated.conditional.model.PkblobsExample)10 PkblobsExample (mbg.test.ib2j5.generated.flat.model.PkblobsExample)10 PkblobsExample (mbg.test.mb3.generated.flat.model.PkblobsExample)10 List (java.util.List)9 ArrayList (java.util.ArrayList)6