use of org.apache.ibatis.session.SqlSession in project camunda-bpm-platform by camunda.
the class TransactionIsolationLevelTest method testTransactionIsolationLevelOnConnection.
@Test
public void testTransactionIsolationLevelOnConnection() {
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
SqlSession sqlSession = processEngineConfiguration.getDbSqlSessionFactory().getSqlSessionFactory().openSession();
try {
int transactionIsolation = sqlSession.getConnection().getTransactionIsolation();
assertEquals("TransactionIsolationLevel for connection is " + transactionIsolation + " instead of " + Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_READ_COMMITTED, transactionIsolation);
} catch (SQLException e) {
e.printStackTrace();
}
}
use of org.apache.ibatis.session.SqlSession in project pinpoint by naver.
the class SqlSessionTestBase method testAndVerifySelectList.
protected final void testAndVerifySelectList() throws Exception {
// Given
final String selectListId = "selectListId";
SqlSession sqlSession = getSqlSession();
// When
sqlSession.selectList(selectListId);
sqlSession.selectList(selectListId, new Object());
sqlSession.selectList(selectListId, new Object(), RowBounds.DEFAULT);
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method selectList1 = sqlSession.getClass().getDeclaredMethod("selectList", String.class);
Method selectList2 = sqlSession.getClass().getDeclaredMethod("selectList", String.class, Object.class);
Method selectList3 = sqlSession.getClass().getDeclaredMethod("selectList", String.class, Object.class, RowBounds.class);
verifier.verifyTrace(event("MYBATIS", selectList1, Expectations.cachedArgs(selectListId)));
verifier.verifyTrace(event("MYBATIS", selectList2, Expectations.cachedArgs(selectListId)));
verifier.verifyTrace(event("MYBATIS", selectList3, Expectations.cachedArgs(selectListId)));
}
use of org.apache.ibatis.session.SqlSession in project pinpoint by naver.
the class SqlSessionTestBase method testAndVerifySelectMap.
protected final void testAndVerifySelectMap() throws Exception {
// Given
final String selectMapId = "selectListId";
SqlSession sqlSession = getSqlSession();
// When
sqlSession.selectMap(selectMapId, "key");
sqlSession.selectMap(selectMapId, new Object(), "key");
sqlSession.selectMap(selectMapId, new Object(), "key", RowBounds.DEFAULT);
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method selectMap1 = sqlSession.getClass().getDeclaredMethod("selectMap", String.class, String.class);
Method selectMap2 = sqlSession.getClass().getDeclaredMethod("selectMap", String.class, Object.class, String.class);
Method selectMap3 = sqlSession.getClass().getDeclaredMethod("selectMap", String.class, Object.class, String.class, RowBounds.class);
verifier.verifyTrace(event("MYBATIS", selectMap1, Expectations.cachedArgs(selectMapId)));
verifier.verifyTrace(event("MYBATIS", selectMap2, Expectations.cachedArgs(selectMapId)));
verifier.verifyTrace(event("MYBATIS", selectMap3, Expectations.cachedArgs(selectMapId)));
}
use of org.apache.ibatis.session.SqlSession in project pinpoint by naver.
the class SqlSessionTestBase method testAndVerifySelectOne.
protected final void testAndVerifySelectOne() throws Exception {
// Given
final String selectOneId = "selectOneId";
SqlSession sqlSession = getSqlSession();
// When
sqlSession.selectOne(selectOneId);
sqlSession.selectOne(selectOneId, new Object());
// Then
PluginTestVerifier verifier = PluginTestVerifierHolder.getInstance();
Method selectOne1 = sqlSession.getClass().getDeclaredMethod("selectOne", String.class);
Method selectOne2 = sqlSession.getClass().getDeclaredMethod("selectOne", String.class, Object.class);
verifier.verifyTrace(event("MYBATIS", selectOne1, Expectations.cachedArgs(selectOneId)));
verifier.verifyTrace(event("MYBATIS", selectOne2, Expectations.cachedArgs(selectOneId)));
}
use of org.apache.ibatis.session.SqlSession in project generator by mybatis.
the class ConditionalJava5Test method testPKFieldsSelectByExampleEscapedFields.
@Test
public void testPKFieldsSelectByExampleEscapedFields() {
SqlSession sqlSession = sqlSessionFactory.openSession();
try {
PkfieldsMapper mapper = sqlSession.getMapper(PkfieldsMapper.class);
Pkfields record = new Pkfields();
record.setFirstname("Fred");
record.setLastname("Flintstone");
record.setId1(1);
record.setId2(1);
record.setWierdField(11);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Wilma");
record.setLastname("Flintstone");
record.setId1(1);
record.setId2(2);
record.setWierdField(22);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Pebbles");
record.setLastname("Flintstone");
record.setId1(1);
record.setId2(3);
record.setWierdField(33);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Barney");
record.setLastname("Rubble");
record.setId1(2);
record.setId2(1);
record.setWierdField(44);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Betty");
record.setLastname("Rubble");
record.setId1(2);
record.setId2(2);
record.setWierdField(55);
mapper.insert(record);
record = new Pkfields();
record.setFirstname("Bamm Bamm");
record.setLastname("Rubble");
record.setId1(2);
record.setId2(3);
record.setWierdField(66);
mapper.insert(record);
List<Integer> values = new ArrayList<>();
values.add(11);
values.add(22);
PkfieldsExample example = new PkfieldsExample();
example.createCriteria().andWierdFieldLessThan(40).andWierdFieldIn(values);
example.setOrderByClause("ID1, ID2");
List<Pkfields> answer = mapper.selectByExample(example);
assertEquals(2, answer.size());
} finally {
sqlSession.close();
}
}
Aggregations