Search in sources :

Example 36 with PkblobsExample

use of mbg.test.ib2j2.generated.flat.model.PkblobsExample 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 37 with PkblobsExample

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

Example 38 with PkblobsExample

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

the class FlatJava2Test 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 = new PkblobsExample();
        rows = dao.countByExample(example);
        assertEquals(2, rows);
    } 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) Pkblobs(mbg.test.ib2j2.generated.flat.model.Pkblobs)

Example 39 with PkblobsExample

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

the class UpdateByExampleTest method testPKBlobsUpdateByExampleWithBLOBs.

public void testPKBlobsUpdateByExampleWithBLOBs() {
    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);
        PkblobsWithBLOBs newRecord = new PkblobsWithBLOBs();
        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());
        assertNull(returnedRecord.getBlob1());
        assertNull(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) SQLException(java.sql.SQLException) List(java.util.List)

Example 40 with PkblobsExample

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

the class HierarchicalJava2Test method testPKBlobsCountByExample.

public void testPKBlobsCountByExample() {
    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().andIdLessThan(new Integer(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.ib2j2.generated.hierarchical.dao.PkblobsDAO) PkblobsExample(mbg.test.ib2j2.generated.hierarchical.model.PkblobsExample) PkblobsWithBLOBs(mbg.test.ib2j2.generated.hierarchical.model.PkblobsWithBLOBs) SQLException(java.sql.SQLException)

Aggregations

SQLException (java.sql.SQLException)30 List (java.util.List)27 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.flat.dao.PkblobsDAO)10 Pkblobs (mbg.test.ib2j5.generated.flat.model.Pkblobs)10 PkblobsExample (mbg.test.ib2j5.generated.flat.model.PkblobsExample)10 PkblobsMapper (mbg.test.mb3.generated.flat.mapper.PkblobsMapper)10 Pkblobs (mbg.test.mb3.generated.flat.model.Pkblobs)10 PkblobsExample (mbg.test.mb3.generated.flat.model.PkblobsExample)10 SqlSession (org.apache.ibatis.session.SqlSession)10