use of mbg.test.mb3.generated.dsql.miscellaneous.mapper.GeneratedalwaystestMapper in project generator by mybatis.
the class GeneratedAlwaysTest method testInsert.
@Test
public void testInsert() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
GeneratedalwaystestMapper mapper = sqlSession.getMapper(GeneratedalwaystestMapper.class);
Generatedalwaystest gaTest = new Generatedalwaystest();
gaTest.setId(1);
gaTest.setName("fred");
gaTest.setIdPlus1(55);
gaTest.setIdPlus2(66);
gaTest.setBlob1(TestUtilities.generateRandomBlob());
int rows = mapper.insert(gaTest);
assertEquals(1, rows);
List<Generatedalwaystest> returnedRecords = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, returnedRecords.size());
Generatedalwaystest returnedRecord = returnedRecords.get(0);
assertEquals(1, returnedRecord.getId().intValue());
assertEquals(2, returnedRecord.getIdPlus1().intValue());
assertEquals(3, returnedRecord.getIdPlus2().intValue());
assertEquals("fred", returnedRecord.getName());
assertTrue(TestUtilities.blobsAreEqual(gaTest.getBlob1(), returnedRecord.getBlob1()));
}
}
use of mbg.test.mb3.generated.dsql.miscellaneous.mapper.GeneratedalwaystestMapper in project generator by mybatis.
the class GeneratedAlwaysTest method testUpdateByExampleWithBlobs.
@Test
public void testUpdateByExampleWithBlobs() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
GeneratedalwaystestMapper mapper = sqlSession.getMapper(GeneratedalwaystestMapper.class);
Generatedalwaystest gaTest = new Generatedalwaystest();
gaTest.setId(1);
gaTest.setName("fred");
// should be ignored
gaTest.setIdPlus1(55);
// should be ignored
gaTest.setIdPlus2(66);
gaTest.setBlob1(TestUtilities.generateRandomBlob());
int rows = mapper.insert(gaTest);
assertEquals(1, rows);
gaTest.setName("barney");
// should be ignored
gaTest.setIdPlus1(77);
// should be ignored
gaTest.setIdPlus2(88);
gaTest.setBlob1(TestUtilities.generateRandomBlob());
rows = mapper.update(dsl -> GeneratedalwaystestMapper.updateAllColumns(gaTest, dsl).where(idPlus1, isEqualTo(2)).and(idPlus2, isEqualTo(3)));
assertEquals(1, rows);
List<Generatedalwaystest> returnedRecords = mapper.select(dsl -> dsl.where(idPlus1, isEqualTo(2)).and(idPlus2, isEqualTo(3)));
assertEquals(1, returnedRecords.size());
Generatedalwaystest returnedRecord = returnedRecords.get(0);
assertEquals(1, returnedRecord.getId().intValue());
assertEquals(2, returnedRecord.getIdPlus1().intValue());
assertEquals(3, returnedRecord.getIdPlus2().intValue());
assertEquals("barney", returnedRecord.getName());
assertTrue(TestUtilities.blobsAreEqual(gaTest.getBlob1(), returnedRecord.getBlob1()));
}
}
use of mbg.test.mb3.generated.dsql.miscellaneous.mapper.GeneratedalwaystestMapper in project generator by mybatis.
the class GeneratedAlwaysTest method testInsertSelective.
@Test
public void testInsertSelective() {
try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
GeneratedalwaystestMapper mapper = sqlSession.getMapper(GeneratedalwaystestMapper.class);
Generatedalwaystest gaTest = new Generatedalwaystest();
gaTest.setId(1);
gaTest.setName("fred");
gaTest.setIdPlus1(55);
gaTest.setIdPlus2(66);
int rows = mapper.insert(gaTest);
assertEquals(1, rows);
List<Generatedalwaystest> returnedRecords = mapper.select(SelectDSLCompleter.allRows());
assertEquals(1, returnedRecords.size());
Generatedalwaystest returnedRecord = returnedRecords.get(0);
assertEquals(1, returnedRecord.getId().intValue());
assertEquals(2, returnedRecord.getIdPlus1().intValue());
assertEquals(3, returnedRecord.getIdPlus2().intValue());
assertEquals("fred", returnedRecord.getName());
assertNull(returnedRecord.getBlob1());
}
}
use of mbg.test.mb3.generated.dsql.miscellaneous.mapper.GeneratedalwaystestMapper in project generator by mybatis.
the class GeneratedAlwaysTest method testUpdateByPrimaryKeyWithBlobs.
@Test
public void testUpdateByPrimaryKeyWithBlobs() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
GeneratedalwaystestMapper mapper = sqlSession.getMapper(GeneratedalwaystestMapper.class);
Generatedalwaystest gaTest = new Generatedalwaystest();
gaTest.setId(1);
gaTest.setName("fred");
// should be ignored
gaTest.setIdPlus1(55);
// should be ignored
gaTest.setIdPlus2(66);
gaTest.setBlob1(TestUtilities.generateRandomBlob());
int rows = mapper.insert(gaTest);
assertEquals(1, rows);
gaTest.setName("barney");
// should be ignored
gaTest.setIdPlus1(77);
// should be ignored
gaTest.setIdPlus2(88);
gaTest.setBlob1(TestUtilities.generateRandomBlob());
rows = mapper.updateByPrimaryKeyWithBLOBs(gaTest);
assertEquals(1, rows);
List<Generatedalwaystest> returnedRecords = mapper.selectByExampleWithBLOBs(null);
assertEquals(1, returnedRecords.size());
Generatedalwaystest returnedRecord = returnedRecords.get(0);
assertEquals(1, returnedRecord.getId().intValue());
assertEquals(2, returnedRecord.getIdPlus1().intValue());
assertEquals(3, returnedRecord.getIdPlus2().intValue());
assertEquals("barney", returnedRecord.getName());
assertTrue(TestUtilities.blobsAreEqual(gaTest.getBlob1(), returnedRecord.getBlob1()));
} finally {
sqlSession.close();
}
}
use of mbg.test.mb3.generated.dsql.miscellaneous.mapper.GeneratedalwaystestMapper in project generator by mybatis.
the class GeneratedAlwaysTest method testInsertSelective.
@Test
public void testInsertSelective() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
GeneratedalwaystestMapper mapper = sqlSession.getMapper(GeneratedalwaystestMapper.class);
Generatedalwaystest gaTest = new Generatedalwaystest();
gaTest.setId(1);
gaTest.setName("fred");
gaTest.setIdPlus1(55);
gaTest.setIdPlus2(66);
int rows = mapper.insert(gaTest);
assertEquals(1, rows);
List<Generatedalwaystest> returnedRecords = mapper.selectByExample(null);
assertEquals(1, returnedRecords.size());
Generatedalwaystest returnedRecord = returnedRecords.get(0);
assertEquals(1, returnedRecord.getId().intValue());
assertEquals(2, returnedRecord.getIdPlus1().intValue());
assertEquals(3, returnedRecord.getIdPlus2().intValue());
assertEquals("fred", returnedRecord.getName());
assertNull(returnedRecord.getBlob1());
} finally {
sqlSession.close();
}
}
Aggregations