use of mbg.test.mb3.generated.conditional.model.FieldsblobsExample in project generator by mybatis.
the class ConditionalJava5Test method testFieldsBlobsSelectByExampleWithBlobsNoCriteria.
@Test
public void testFieldsBlobsSelectByExampleWithBlobsNoCriteria() {
FieldsblobsDAO dao = getFieldsblobsDAO();
try {
FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
record = new FieldsblobsWithBLOBs();
record.setFirstname("Scott");
record.setLastname("Jones");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
FieldsblobsExample example = new FieldsblobsExample();
example.createCriteria();
List<FieldsblobsWithBLOBs> answer = dao.selectByExampleWithBLOBs(example);
assertEquals(2, answer.size());
} catch (SQLException e) {
fail(e.getMessage());
}
}
use of mbg.test.mb3.generated.conditional.model.FieldsblobsExample in project generator by mybatis.
the class ConditionalJava5Test method testFieldsBlobsSelectByExampleWithoutBlobs.
@Test
public void testFieldsBlobsSelectByExampleWithoutBlobs() {
FieldsblobsDAO dao = getFieldsblobsDAO();
try {
FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
record = new FieldsblobsWithBLOBs();
record.setFirstname("Scott");
record.setLastname("Jones");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
FieldsblobsExample example = new FieldsblobsExample();
example.createCriteria().andFirstnameLike("S%");
List<Fieldsblobs> answer = dao.selectByExampleWithoutBLOBs(example);
assertEquals(1, answer.size());
Fieldsblobs newRecord = answer.get(0);
assertFalse(newRecord instanceof FieldsblobsWithBLOBs);
assertEquals(record.getFirstname(), newRecord.getFirstname());
assertEquals(record.getLastname(), newRecord.getLastname());
} catch (SQLException e) {
fail(e.getMessage());
}
}
use of mbg.test.mb3.generated.conditional.model.FieldsblobsExample in project generator by mybatis.
the class ConditionalJava5Test method testFieldsBlobsCountByExample.
@Test
public void testFieldsBlobsCountByExample() {
FieldsblobsDAO dao = getFieldsblobsDAO();
try {
FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
record = new FieldsblobsWithBLOBs();
record.setFirstname("Scott");
record.setLastname("Jones");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
FieldsblobsExample example = new FieldsblobsExample();
example.createCriteria().andFirstnameLike("S%");
long rows = dao.countByExample(example);
assertEquals(1, rows);
example.clear();
rows = dao.countByExample(example);
assertEquals(2, rows);
} catch (SQLException e) {
fail(e.getMessage());
}
}
use of mbg.test.mb3.generated.conditional.model.FieldsblobsExample in project generator by mybatis.
the class ConditionalJava5Test method testFieldsBlobsDeleteByExample.
@Test
public void testFieldsBlobsDeleteByExample() {
FieldsblobsDAO dao = getFieldsblobsDAO();
try {
FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
record = new FieldsblobsWithBLOBs();
record.setFirstname("Scott");
record.setLastname("Jones");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
FieldsblobsExample example = new FieldsblobsExample();
List<Fieldsblobs> answer = dao.selectByExampleWithoutBLOBs(example);
assertEquals(2, answer.size());
example = new FieldsblobsExample();
example.createCriteria().andFirstnameLike("S%");
int rows = dao.deleteByExample(example);
assertEquals(1, rows);
example = new FieldsblobsExample();
answer = dao.selectByExampleWithoutBLOBs(example);
assertEquals(1, answer.size());
} catch (SQLException e) {
fail(e.getMessage());
}
}
use of mbg.test.mb3.generated.conditional.model.FieldsblobsExample in project generator by mybatis.
the class UpdateByExampleTest method testFieldsBlobsUpdateByExampleWithBLOBs.
@Test
public void testFieldsBlobsUpdateByExampleWithBLOBs() {
FieldsblobsDAO dao = getFieldsblobsDAO();
try {
FieldsblobsWithBLOBs record = new FieldsblobsWithBLOBs();
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
record = new FieldsblobsWithBLOBs();
record.setFirstname("Scott");
record.setLastname("Jones");
record.setBlob1(generateRandomBlob());
record.setBlob2(generateRandomBlob());
dao.insert(record);
FieldsblobsWithBLOBs newRecord = new FieldsblobsWithBLOBs();
newRecord.setFirstname("Scott");
newRecord.setLastname("Doe");
FieldsblobsExample example = new FieldsblobsExample();
example.createCriteria().andFirstnameLike("S%");
int rows = dao.updateByExample(newRecord, example);
assertEquals(1, rows);
List<FieldsblobsWithBLOBs> answer = dao.selectByExampleWithBLOBs(example);
assertEquals(1, answer.size());
FieldsblobsWithBLOBs returnedRecord = answer.get(0);
assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
assertEquals(newRecord.getLastname(), returnedRecord.getLastname());
assertNull(returnedRecord.getBlob1());
assertNull(returnedRecord.getBlob2());
} catch (SQLException e) {
fail(e.getMessage());
}
}
Aggregations