Search in sources :

Example 1 with EnumtestMapper

use of mbg.test.mb3.generated.annotated.miscellaneous.mapper.EnumtestMapper in project generator by mybatis.

the class MiscellaneousTest method testEnum.

@Test
public void testEnum() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        EnumtestMapper mapper = sqlSession.getMapper(EnumtestMapper.class);
        Enumtest enumTest = new Enumtest();
        enumTest.setId(1);
        enumTest.setName(TestEnum.FRED);
        int rows = mapper.insert(enumTest);
        assertEquals(1, rows);
        List<Enumtest> returnedRecords = mapper.selectByExample(null);
        assertEquals(1, returnedRecords.size());
        Enumtest returnedRecord = returnedRecords.get(0);
        assertEquals(1, returnedRecord.getId().intValue());
        assertEquals(TestEnum.FRED, returnedRecord.getName());
    } finally {
        sqlSession.close();
    }
}
Also used : EnumtestMapper(mbg.test.mb3.generated.annotated.miscellaneous.mapper.EnumtestMapper) SqlSession(org.apache.ibatis.session.SqlSession) Enumtest(mbg.test.mb3.generated.annotated.miscellaneous.model.Enumtest) Test(org.junit.jupiter.api.Test)

Example 2 with EnumtestMapper

use of mbg.test.mb3.generated.annotated.miscellaneous.mapper.EnumtestMapper in project generator by mybatis.

the class MiscellaneousTest method testEnum.

@Test
public void testEnum() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        EnumtestMapper mapper = sqlSession.getMapper(EnumtestMapper.class);
        Enumtest enumTest = new Enumtest();
        enumTest.setId(1);
        enumTest.setName(TestEnum.FRED);
        int rows = mapper.insert(enumTest);
        assertEquals(1, rows);
        List<Enumtest> returnedRecords = mapper.selectByExample(null);
        assertEquals(1, returnedRecords.size());
        Enumtest returnedRecord = returnedRecords.get(0);
        assertEquals(1, returnedRecord.getId().intValue());
        assertEquals(TestEnum.FRED, returnedRecord.getName());
    } finally {
        sqlSession.close();
    }
}
Also used : EnumtestMapper(mbg.test.mb3.generated.mixed.miscellaneous.mapper.EnumtestMapper) SqlSession(org.apache.ibatis.session.SqlSession) Enumtest(mbg.test.mb3.generated.mixed.miscellaneous.model.Enumtest) Test(org.junit.jupiter.api.Test)

Example 3 with EnumtestMapper

use of mbg.test.mb3.generated.annotated.miscellaneous.mapper.EnumtestMapper in project generator by mybatis.

the class MiscellaneousTest method testEnum.

@Test
public void testEnum() {
    SqlSession sqlSession = sqlSessionFactory.openSession();
    try {
        EnumtestMapper mapper = sqlSession.getMapper(EnumtestMapper.class);
        Enumtest enumTest = new Enumtest();
        enumTest.setId(1);
        enumTest.setName(TestEnum.FRED);
        int rows = mapper.insert(enumTest);
        assertEquals(1, rows);
        List<Enumtest> returnedRecords = mapper.selectByExample(null);
        assertEquals(1, returnedRecords.size());
        Enumtest returnedRecord = returnedRecords.get(0);
        assertEquals(1, returnedRecord.getId().intValue());
        assertEquals(TestEnum.FRED, returnedRecord.getName());
    } finally {
        sqlSession.close();
    }
}
Also used : EnumtestMapper(mbg.test.mb3.generated.miscellaneous.mapper.EnumtestMapper) SqlSession(org.apache.ibatis.session.SqlSession) Enumtest(mbg.test.mb3.generated.miscellaneous.model.Enumtest) Test(org.junit.jupiter.api.Test)

Example 4 with EnumtestMapper

use of mbg.test.mb3.generated.annotated.miscellaneous.mapper.EnumtestMapper in project generator by mybatis.

the class MiscellaneousTest method testEnumInsertMultiple.

@Test
public void testEnumInsertMultiple() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        EnumtestMapper mapper = sqlSession.getMapper(EnumtestMapper.class);
        List<Enumtest> records = new ArrayList<>();
        Enumtest enumTest = new Enumtest();
        enumTest.setId(1);
        enumTest.setName(TestEnum.FRED);
        records.add(enumTest);
        enumTest = new Enumtest();
        enumTest.setId(2);
        enumTest.setName(TestEnum.BARNEY);
        records.add(enumTest);
        int rows = mapper.insertMultiple(records);
        assertEquals(2, rows);
        List<Enumtest> returnedRecords = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(2, returnedRecords.size());
        Enumtest returnedRecord = returnedRecords.get(0);
        assertEquals(1, returnedRecord.getId().intValue());
        assertEquals(TestEnum.FRED, returnedRecord.getName());
    }
}
Also used : EnumtestMapper(mbg.test.mb3.generated.dsql.miscellaneous.mapper.EnumtestMapper) SqlSession(org.apache.ibatis.session.SqlSession) Enumtest(mbg.test.mb3.generated.dsql.miscellaneous.model.Enumtest) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Example 5 with EnumtestMapper

use of mbg.test.mb3.generated.annotated.miscellaneous.mapper.EnumtestMapper in project generator by mybatis.

the class MiscellaneousTest method testEnum.

@Test
public void testEnum() {
    try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
        EnumtestMapper mapper = sqlSession.getMapper(EnumtestMapper.class);
        Enumtest enumTest = new Enumtest();
        enumTest.setId(1);
        enumTest.setName(TestEnum.FRED);
        int rows = mapper.insert(enumTest);
        assertEquals(1, rows);
        List<Enumtest> returnedRecords = mapper.select(SelectDSLCompleter.allRows());
        assertEquals(1, returnedRecords.size());
        Enumtest returnedRecord = returnedRecords.get(0);
        assertEquals(1, returnedRecord.getId().intValue());
        assertEquals(TestEnum.FRED, returnedRecord.getName());
    }
}
Also used : EnumtestMapper(mbg.test.mb3.generated.dsql.miscellaneous.mapper.EnumtestMapper) SqlSession(org.apache.ibatis.session.SqlSession) Enumtest(mbg.test.mb3.generated.dsql.miscellaneous.model.Enumtest) Test(org.junit.jupiter.api.Test)

Aggregations

SqlSession (org.apache.ibatis.session.SqlSession)5 Test (org.junit.jupiter.api.Test)5 EnumtestMapper (mbg.test.mb3.generated.dsql.miscellaneous.mapper.EnumtestMapper)2 Enumtest (mbg.test.mb3.generated.dsql.miscellaneous.model.Enumtest)2 ArrayList (java.util.ArrayList)1 EnumtestMapper (mbg.test.mb3.generated.annotated.miscellaneous.mapper.EnumtestMapper)1 Enumtest (mbg.test.mb3.generated.annotated.miscellaneous.model.Enumtest)1 EnumtestMapper (mbg.test.mb3.generated.miscellaneous.mapper.EnumtestMapper)1 Enumtest (mbg.test.mb3.generated.miscellaneous.model.Enumtest)1 EnumtestMapper (mbg.test.mb3.generated.mixed.miscellaneous.mapper.EnumtestMapper)1 Enumtest (mbg.test.mb3.generated.mixed.miscellaneous.model.Enumtest)1