use of mbg.test.mb3.generated.conditional.immutable.mapper.PkfieldsblobsMapper in project generator by mybatis.
the class DynamicSqlTest method testPKFieldsBlobsUpdateByPrimaryKeySelective.
@Test
public void testPKFieldsBlobsUpdateByPrimaryKeySelective() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkfieldsblobsMapper mapper = sqlSession.getMapper(PkfieldsblobsMapper.class);
Pkfieldsblobs record = new Pkfieldsblobs();
record.setId1(3);
record.setId2(4);
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setBlob1(generateRandomBlob());
mapper.insert(record);
Pkfieldsblobs updateRecord = new Pkfieldsblobs();
updateRecord.setId1(3);
updateRecord.setId2(4);
updateRecord.setLastname("Jones");
int rows = mapper.updateByPrimaryKeySelective(updateRecord);
assertEquals(1, rows);
Optional<Pkfieldsblobs> returnedRecord = mapper.selectByPrimaryKey(3, 4);
assertThat(returnedRecord).hasValueSatisfying(rr -> {
assertEquals(record.getFirstname(), rr.getFirstname());
assertEquals(updateRecord.getLastname(), rr.getLastname());
assertEquals(record.getId1(), rr.getId1());
assertEquals(record.getId2(), rr.getId2());
assertTrue(blobsAreEqual(record.getBlob1(), rr.getBlob1()));
});
}
}
use of mbg.test.mb3.generated.conditional.immutable.mapper.PkfieldsblobsMapper in project generator by mybatis.
the class DynamicSqlTest method testPKFieldsBlobsDeleteByPrimaryKey.
@Test
public void testPKFieldsBlobsDeleteByPrimaryKey() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
PkfieldsblobsMapper mapper = sqlSession.getMapper(PkfieldsblobsMapper.class);
Pkfieldsblobs record = new Pkfieldsblobs();
record.setId1(3);
record.setId2(4);
record.setFirstname("Jeff");
record.setLastname("Smith");
record.setBlob1(generateRandomBlob());
mapper.insert(record);
record = new Pkfieldsblobs();
record.setId1(5);
record.setId2(6);
record.setFirstname("Scott");
record.setLastname("Jones");
record.setBlob1(generateRandomBlob());
mapper.insert(record);
List<Pkfieldsblobs> answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(2, answer.size());
int rows = mapper.deleteByPrimaryKey(5, 6);
assertEquals(1, rows);
answer = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, answer.size());
}
}
use of mbg.test.mb3.generated.conditional.immutable.mapper.PkfieldsblobsMapper in project generator by mybatis.
the class SimpleAnnotatedTest method testPkfieldsblobs.
@Test
public void testPkfieldsblobs() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkfieldsblobsMapper mapper = sqlSession.getMapper(PkfieldsblobsMapper.class);
Pkfieldsblobs record = new Pkfieldsblobs();
record.setId1(1);
record.setId2(1);
record.setBlob1(TestUtilities.generateRandomBlob());
int rows = mapper.insert(record);
assertEquals(1, rows);
record = new Pkfieldsblobs();
record.setId1(2);
record.setId2(2);
record.setBlob1(TestUtilities.generateRandomBlob());
rows = mapper.insert(record);
assertEquals(1, rows);
List<Pkfieldsblobs> records = mapper.selectAll();
assertEquals(2, records.size());
Pkfieldsblobs returnedRecord = mapper.selectByPrimaryKey(record.getId1(), record.getId2());
assertNotNull(returnedRecord);
assertTrue(TestUtilities.blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
record.setBlob1(TestUtilities.generateRandomBlob());
rows = mapper.updateByPrimaryKey(record);
assertEquals(1, rows);
returnedRecord = mapper.selectByPrimaryKey(record.getId1(), record.getId2());
assertNotNull(returnedRecord);
assertTrue(TestUtilities.blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
rows = mapper.deleteByPrimaryKey(record.getId1(), record.getId2());
assertEquals(1, rows);
records = mapper.selectAll();
assertEquals(1, records.size());
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.conditional.immutable.mapper.PkfieldsblobsMapper in project generator by mybatis.
the class UpdateByExampleTest method testPKFieldsBlobsUpdateByExampleWithoutBLOBs.
@Test
public void testPKFieldsBlobsUpdateByExampleWithoutBLOBs() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkfieldsblobsMapper mapper = sqlSession.getMapper(PkfieldsblobsMapper.class);
PkfieldsblobsWithBLOBs record = new PkfieldsblobsWithBLOBs(3, 4, "Jeff", "Smith", generateRandomBlob());
mapper.insert(record);
record = new PkfieldsblobsWithBLOBs(5, 6, "Scott", "Jones", generateRandomBlob());
mapper.insert(record);
Pkfieldsblobs newRecord = new Pkfieldsblobs(5, 8, "Fred", null);
PkfieldsblobsExample example = new PkfieldsblobsExample();
example.createCriteria().andId1EqualTo(5);
int rows = mapper.updateByExample(newRecord, example);
assertEquals(1, rows);
List<PkfieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
assertEquals(1, answer.size());
PkfieldsblobsWithBLOBs returnedRecord = answer.get(0);
assertEquals(newRecord.getId1(), returnedRecord.getId1());
assertEquals(newRecord.getId2(), returnedRecord.getId2());
assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
assertNull(returnedRecord.getLastname());
assertTrue(blobsAreEqual(record.getBlob1(), returnedRecord.getBlob1()));
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.conditional.immutable.mapper.PkfieldsblobsMapper in project generator by mybatis.
the class UpdateByExampleTest method testPKFieldsBlobsUpdateByExampleWithBLOBs.
@Test
public void testPKFieldsBlobsUpdateByExampleWithBLOBs() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkfieldsblobsMapper mapper = sqlSession.getMapper(PkfieldsblobsMapper.class);
PkfieldsblobsWithBLOBs record = new PkfieldsblobsWithBLOBs(3, 4, "Jeff", "Smith", generateRandomBlob());
mapper.insert(record);
record = new PkfieldsblobsWithBLOBs(5, 6, "Scott", "Jones", generateRandomBlob());
mapper.insert(record);
PkfieldsblobsWithBLOBs newRecord = new PkfieldsblobsWithBLOBs(3, 8, "Fred", null, null);
PkfieldsblobsExample example = new PkfieldsblobsExample();
example.createCriteria().andId1EqualTo(3);
int rows = mapper.updateByExampleWithBLOBs(newRecord, example);
assertEquals(1, rows);
List<PkfieldsblobsWithBLOBs> answer = mapper.selectByExampleWithBLOBs(example);
assertEquals(1, answer.size());
PkfieldsblobsWithBLOBs returnedRecord = answer.get(0);
assertEquals(newRecord.getId1(), returnedRecord.getId1());
assertEquals(newRecord.getId2(), returnedRecord.getId2());
assertEquals(newRecord.getFirstname(), returnedRecord.getFirstname());
assertNull(returnedRecord.getLastname());
assertNull(returnedRecord.getBlob1());
} finally {
sqlSession.close();
}
}
Aggregations