Search in sources :

Example 1 with GeneratedalwaystestCriteria

use of mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria in project generator by mybatis.

the class GeneratedAlwaysTest method testUpdateByExampleSelective.

@Test
public void testUpdateByExampleSelective() {
    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(null);
        // should be ignored
        gaTest.setIdPlus1(77);
        // should be ignored
        gaTest.setIdPlus2(88);
        gaTest.setBlob1(TestUtilities.generateRandomBlob());
        GeneratedalwaystestCriteria gaCriteria = new GeneratedalwaystestCriteria();
        gaCriteria.or().andIdPlus1EqualTo(2).andIdPlus2EqualTo(3);
        rows = mapper.updateByExampleSelective(gaTest, gaCriteria);
        assertEquals(1, rows);
        List<Generatedalwaystest> returnedRecords = mapper.selectByExampleWithBLOBs(gaCriteria);
        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()));
    } finally {
        sqlSession.close();
    }
}
Also used : Generatedalwaystest(mbg.test.mb3.generated.annotated.miscellaneous.model.Generatedalwaystest) SqlSession(org.apache.ibatis.session.SqlSession) GeneratedalwaystestMapper(mbg.test.mb3.generated.annotated.miscellaneous.mapper.GeneratedalwaystestMapper) GeneratedalwaystestCriteria(mbg.test.mb3.generated.annotated.miscellaneous.model.GeneratedalwaystestCriteria) Test(org.junit.jupiter.api.Test)

Example 2 with GeneratedalwaystestCriteria

use of mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria in project generator by mybatis.

the class GeneratedAlwaysTest method testUpdateByExampleWithBlobs.

@Test
public void testUpdateByExampleWithBlobs() {
    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());
        GeneratedalwaystestCriteria gaCriteria = new GeneratedalwaystestCriteria();
        gaCriteria.or().andIdPlus1EqualTo(2).andIdPlus2EqualTo(3);
        rows = mapper.updateByExampleWithBLOBs(gaTest, gaCriteria);
        assertEquals(1, rows);
        List<Generatedalwaystest> returnedRecords = mapper.selectByExampleWithBLOBs(gaCriteria);
        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();
    }
}
Also used : Generatedalwaystest(mbg.test.mb3.generated.annotated.miscellaneous.model.Generatedalwaystest) SqlSession(org.apache.ibatis.session.SqlSession) GeneratedalwaystestMapper(mbg.test.mb3.generated.annotated.miscellaneous.mapper.GeneratedalwaystestMapper) GeneratedalwaystestCriteria(mbg.test.mb3.generated.annotated.miscellaneous.model.GeneratedalwaystestCriteria) Test(org.junit.jupiter.api.Test)

Example 3 with GeneratedalwaystestCriteria

use of mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria in project generator by mybatis.

the class GeneratedAlwaysTest method testUpdateByExample.

@Test
public void testUpdateByExample() {
    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);
        byte[] originalBlob = gaTest.getBlob1();
        gaTest.setName("barney");
        // should be ignored
        gaTest.setIdPlus1(77);
        // should be ignored
        gaTest.setIdPlus2(88);
        gaTest.setBlob1(TestUtilities.generateRandomBlob());
        GeneratedalwaystestCriteria gaCriteria = new GeneratedalwaystestCriteria();
        gaCriteria.or().andIdPlus1EqualTo(2).andIdPlus2EqualTo(3);
        rows = mapper.updateByExample(gaTest, gaCriteria);
        assertEquals(1, rows);
        List<Generatedalwaystest> returnedRecords = mapper.selectByExampleWithBLOBs(gaCriteria);
        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());
        // should not have update the BLOB in regular update by primary key
        assertTrue(TestUtilities.blobsAreEqual(originalBlob, returnedRecord.getBlob1()));
    } finally {
        sqlSession.close();
    }
}
Also used : Generatedalwaystest(mbg.test.mb3.generated.annotated.miscellaneous.model.Generatedalwaystest) SqlSession(org.apache.ibatis.session.SqlSession) GeneratedalwaystestMapper(mbg.test.mb3.generated.annotated.miscellaneous.mapper.GeneratedalwaystestMapper) GeneratedalwaystestCriteria(mbg.test.mb3.generated.annotated.miscellaneous.model.GeneratedalwaystestCriteria) Test(org.junit.jupiter.api.Test)

Example 4 with GeneratedalwaystestCriteria

use of mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria in project generator by mybatis.

the class GeneratedAlwaysTest method testUpdateByExampleWithBlobs.

@Test
public void testUpdateByExampleWithBlobs() {
    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());
        GeneratedalwaystestCriteria gaCriteria = new GeneratedalwaystestCriteria();
        gaCriteria.or().andIdPlus1EqualTo(2).andIdPlus2EqualTo(3);
        rows = mapper.updateByExampleWithBLOBs(gaTest, gaCriteria);
        assertEquals(1, rows);
        List<Generatedalwaystest> returnedRecords = mapper.selectByExampleWithBLOBs(gaCriteria);
        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();
    }
}
Also used : Generatedalwaystest(mbg.test.mb3.generated.miscellaneous.model.Generatedalwaystest) SqlSession(org.apache.ibatis.session.SqlSession) GeneratedalwaystestMapper(mbg.test.mb3.generated.miscellaneous.mapper.GeneratedalwaystestMapper) GeneratedalwaystestCriteria(mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria) Test(org.junit.jupiter.api.Test)

Example 5 with GeneratedalwaystestCriteria

use of mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria in project generator by mybatis.

the class GeneratedAlwaysTest method testUpdateByExampleSelective.

@Test
public void testUpdateByExampleSelective() {
    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(null);
        // should be ignored
        gaTest.setIdPlus1(77);
        // should be ignored
        gaTest.setIdPlus2(88);
        gaTest.setBlob1(TestUtilities.generateRandomBlob());
        GeneratedalwaystestCriteria gaCriteria = new GeneratedalwaystestCriteria();
        gaCriteria.or().andIdPlus1EqualTo(2).andIdPlus2EqualTo(3);
        rows = mapper.updateByExampleSelective(gaTest, gaCriteria);
        assertEquals(1, rows);
        List<Generatedalwaystest> returnedRecords = mapper.selectByExampleWithBLOBs(gaCriteria);
        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()));
    } finally {
        sqlSession.close();
    }
}
Also used : Generatedalwaystest(mbg.test.mb3.generated.miscellaneous.model.Generatedalwaystest) SqlSession(org.apache.ibatis.session.SqlSession) GeneratedalwaystestMapper(mbg.test.mb3.generated.miscellaneous.mapper.GeneratedalwaystestMapper) GeneratedalwaystestCriteria(mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria) Test(org.junit.jupiter.api.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)6 Test (org.junit.jupiter.api.Test)6 GeneratedalwaystestMapper (mbg.test.mb3.generated.annotated.miscellaneous.mapper.GeneratedalwaystestMapper)3 Generatedalwaystest (mbg.test.mb3.generated.annotated.miscellaneous.model.Generatedalwaystest)3 GeneratedalwaystestCriteria (mbg.test.mb3.generated.annotated.miscellaneous.model.GeneratedalwaystestCriteria)3 GeneratedalwaystestMapper (mbg.test.mb3.generated.miscellaneous.mapper.GeneratedalwaystestMapper)3 Generatedalwaystest (mbg.test.mb3.generated.miscellaneous.model.Generatedalwaystest)3 GeneratedalwaystestCriteria (mbg.test.mb3.generated.miscellaneous.model.GeneratedalwaystestCriteria)3