summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-04-29 13:45:03 +0200
committerSimon Brandhof <simon.brandhof@gmail.com>2014-04-29 13:45:12 +0200
commit3a742bb8b929c6e1d7f12405fd82935b75c287de (patch)
tree9f48acdcd45347818d9b574d3f9795962e476d45
parent5b1b10e44eb2948eeac7ac9eb2a290d271dbac44 (diff)
downloadsonarqube-3a742bb8b929c6e1d7f12405fd82935b75c287de.tar.gz
sonarqube-3a742bb8b929c6e1d7f12405fd82935b75c287de.zip
Remove coupling with mybatis SqlSession by using internal DbSession.
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/ComponentDataPersister.java3
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java6
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java3
-rw-r--r--sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java11
-rw-r--r--sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/component/db/ComponentDao.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/dashboard/ActiveDashboardDao.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/dashboard/DashboardDao.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/db/BaseDao.java23
-rw-r--r--sonar-core/src/main/java/org/sonar/core/db/Dao.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/core/duplication/DuplicationDao.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanDao.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanStatsDao.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java12
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java14
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueStatsDao.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java5
-rw-r--r--sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDao.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/measure/db/MeasureFilterDao.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/notification/db/NotificationQueueDao.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java24
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java (renamed from sonar-core/src/main/java/org/sonar/core/persistence/SonarSession.java)12
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java28
-rw-r--r--sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/preview/PreviewCache.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java31
-rw-r--r--sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualitygate/db/ProjectQgateAssociationDao.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDao.java12
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateDao.java12
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java44
-rw-r--r--sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java30
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java32
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java9
-rw-r--r--sonar-core/src/main/java/org/sonar/core/resource/ResourceKeyUpdaterDao.java7
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java32
-rw-r--r--sonar-core/src/main/java/org/sonar/core/rule/RuleTagDao.java10
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java22
-rw-r--r--sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/template/LoadedTemplateDao.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java8
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java6
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/GroupMembershipDao.java2
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/RoleDao.java16
-rw-r--r--sonar-core/src/main/java/org/sonar/core/user/UserDao.java12
-rw-r--r--sonar-core/src/test/java/org/sonar/core/permission/PermissionTemplateDaoTest.java7
-rw-r--r--sonar-core/src/test/java/org/sonar/core/preview/PreviewCacheTest.java8
-rw-r--r--sonar-server/src/main/java/org/sonar/server/cluster/LocalNonBlockingWorkQueue.java18
-rw-r--r--sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrator.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java14
-rw-r--r--sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java16
-rw-r--r--sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/ESActiveRule.java6
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperations.java16
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackup.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java16
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java12
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java8
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java14
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java18
-rw-r--r--sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/source/DeprecatedSourceDecorator.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/source/HtmlSourceDecorator.java2
-rw-r--r--sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityProfiles.java2
-rw-r--r--sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigratorTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java9
-rw-r--r--sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java23
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java19
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/ESActiveRuleTest.java13
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperationsTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackupTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileOperationsTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/source/DeprecatedSourceDecoratorTest.java6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/startup/RegisterQualityProfilesTest.java6
92 files changed, 450 insertions, 426 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/ComponentDataPersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/ComponentDataPersister.java
index 076f1eead68..39b0327fee5 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/ComponentDataPersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/ComponentDataPersister.java
@@ -21,6 +21,7 @@ package org.sonar.batch.index;
import org.sonar.api.database.model.Snapshot;
import org.sonar.core.persistence.BatchSession;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import org.sonar.core.source.db.SnapshotDataDao;
import org.sonar.core.source.db.SnapshotDataDto;
@@ -43,7 +44,7 @@ public class ComponentDataPersister implements ScanPersister {
@Override
public void persist() {
- BatchSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
for (Map.Entry<String, Snapshot> componentEntry : snapshots.snapshots()) {
String componentKey = componentEntry.getKey();
Snapshot snapshot = componentEntry.getValue();
diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
index 2e1c8995bac..e394f3199ee 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/index/MeasurePersister.java
@@ -175,7 +175,7 @@ public final class MeasurePersister {
}
private void insert(Iterable<MeasureModelAndDetails> values) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
MeasureMapper mapper = session.getMapper(MeasureMapper.class);
@@ -198,7 +198,7 @@ public final class MeasurePersister {
MeasureModel value = model(measure);
value.setSnapshotId(snapshot.getId());
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
MeasureMapper mapper = session.getMapper(MeasureMapper.class);
@@ -217,7 +217,7 @@ public final class MeasurePersister {
value.setId(measure.getId());
value.setSnapshotId(snapshot.getId());
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
MeasureMapper mapper = session.getMapper(MeasureMapper.class);
diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java b/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java
index bf1c7f0a932..3fc0f17db9a 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java
@@ -33,6 +33,7 @@ import org.sonar.core.graph.graphson.GraphsonWriter;
import org.sonar.core.graph.jdbc.GraphDto;
import org.sonar.core.graph.jdbc.GraphDtoMapper;
import org.sonar.core.persistence.BatchSession;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import java.io.StringWriter;
@@ -49,7 +50,7 @@ public class GraphPersister implements ScanPersister {
}
public void persist() {
- BatchSession session = myBatis.openBatchSession();
+ DbSession session = myBatis.openSession(true);
GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
try {
for (ComponentVertex component : projectGraph.getComponents()) {
diff --git a/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java b/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java
index 2598d9bec67..d18ed3e690c 100644
--- a/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java
+++ b/sonar-core/src/main/java/org/sonar/core/cluster/NullQueue.java
@@ -19,22 +19,23 @@
*/
package org.sonar.core.cluster;
+import javax.annotation.CheckForNull;
public class NullQueue implements WorkQueue {
- public NullQueue(){
+ @Override
+ public void enqueue(IndexAction<?> action) {
}
@Override
- public Integer enqueue(IndexAction<?>... action) {
- // TODO Auto-generated method stub
- return null;
+ public void enqueue(Iterable<IndexAction<?>> actions) {
+
}
+ @CheckForNull
@Override
public IndexAction<?> dequeue() {
- // TODO Auto-generated method stub
return null;
}
}
diff --git a/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java b/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java
index d6ede47fe26..9c5ffcfbe02 100644
--- a/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java
+++ b/sonar-core/src/main/java/org/sonar/core/cluster/WorkQueue.java
@@ -19,11 +19,15 @@
*/
package org.sonar.core.cluster;
+import javax.annotation.CheckForNull;
public interface WorkQueue {
- Integer enqueue(IndexAction<?>... action);
+ void enqueue(IndexAction<?> action);
+ void enqueue(Iterable<IndexAction<?>> actions);
+
+ @CheckForNull
IndexAction<?> dequeue();
}
diff --git a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentDao.java b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentDao.java
index 9b378223e9e..ecd4c8148c9 100644
--- a/sonar-core/src/main/java/org/sonar/core/component/db/ComponentDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/component/db/ComponentDao.java
@@ -38,7 +38,7 @@ public class ComponentDao {
}
public Collection<ComponentDto> selectComponent(ComponentQuery query) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return select(query, session);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/dashboard/ActiveDashboardDao.java b/sonar-core/src/main/java/org/sonar/core/dashboard/ActiveDashboardDao.java
index f0ae8ce7658..3dc8e42b55f 100644
--- a/sonar-core/src/main/java/org/sonar/core/dashboard/ActiveDashboardDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/dashboard/ActiveDashboardDao.java
@@ -33,7 +33,7 @@ public class ActiveDashboardDao implements BatchComponent, ServerComponent {
}
public void insert(ActiveDashboardDto activeDashboardDto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
ActiveDashboardMapper mapper = session.getMapper(ActiveDashboardMapper.class);
try {
mapper.insert(activeDashboardDto);
@@ -44,7 +44,7 @@ public class ActiveDashboardDao implements BatchComponent, ServerComponent {
}
public int selectMaxOrderIndexForNullUser() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
ActiveDashboardMapper mapper = session.getMapper(ActiveDashboardMapper.class);
try {
Integer max = mapper.selectMaxOrderIndexForNullUser();
diff --git a/sonar-core/src/main/java/org/sonar/core/dashboard/DashboardDao.java b/sonar-core/src/main/java/org/sonar/core/dashboard/DashboardDao.java
index aefd875217e..a0cccf0854a 100644
--- a/sonar-core/src/main/java/org/sonar/core/dashboard/DashboardDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/dashboard/DashboardDao.java
@@ -33,7 +33,7 @@ public class DashboardDao implements BatchComponent, ServerComponent {
}
public DashboardDto selectGlobalDashboard(String name) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
DashboardMapper mapper = session.getMapper(DashboardMapper.class);
return mapper.selectGlobalDashboard(name);
@@ -43,7 +43,7 @@ public class DashboardDao implements BatchComponent, ServerComponent {
}
public void insert(DashboardDto dashboardDto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
DashboardMapper dashboardMapper = session.getMapper(DashboardMapper.class);
WidgetMapper widgetMapper = session.getMapper(WidgetMapper.class);
WidgetPropertyMapper widgetPropertyMapper = session.getMapper(WidgetPropertyMapper.class);
diff --git a/sonar-core/src/main/java/org/sonar/core/db/BaseDao.java b/sonar-core/src/main/java/org/sonar/core/db/BaseDao.java
index a5bf24f6c6c..bdc6143a21d 100644
--- a/sonar-core/src/main/java/org/sonar/core/db/BaseDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/db/BaseDao.java
@@ -19,11 +19,10 @@
*/
package org.sonar.core.db;
-import org.sonar.core.cluster.IndexAction;
-
import org.apache.ibatis.session.SqlSession;
+import org.sonar.core.cluster.IndexAction;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import java.io.Serializable;
@@ -54,14 +53,14 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
@Override
public E getByKey(K key) {
- SonarSession session = getMyBatis().openSession();
+ DbSession session = getMyBatis().openSession(false);
E item = this.doGetByKey(key, session);
MyBatis.closeQuietly(session);
return item;
}
@Override
- public E update(E item, SonarSession session) {
+ public E update(E item, DbSession session) {
session.enqueue(new IndexAction(this.getIndexName(),
IndexAction.Method.UPDATE, item.getKey()));
return this.doUpdate(item, session);
@@ -69,7 +68,7 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
@Override
public E update(E item) {
- SonarSession session = getMyBatis().openSession();
+ DbSession session = getMyBatis().openSession(false);
try {
this.update(item, session);
session.commit();
@@ -80,7 +79,7 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
}
@Override
- public E insert(E item, SonarSession session) {
+ public E insert(E item, DbSession session) {
session.enqueue(new IndexAction(this.getIndexName(),
IndexAction.Method.INSERT, item.getKey()));
return this.doInsert(item, session);
@@ -88,7 +87,7 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
@Override
public E insert(E item) {
- SonarSession session = getMyBatis().openSession();
+ DbSession session = getMyBatis().openSession(false);
try {
this.insert(item, session);
session.commit();
@@ -99,7 +98,7 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
}
@Override
- public void delete(E item, SonarSession session) {
+ public void delete(E item, DbSession session) {
session.enqueue(new IndexAction(this.getIndexName(),
IndexAction.Method.DELETE, item.getKey()));
this.doDelete(item, session);
@@ -107,7 +106,7 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
@Override
public void delete(E item) {
- SonarSession session = getMyBatis().openSession();
+ DbSession session = getMyBatis().openSession(false);
try {
this.delete(item, session);
session.commit();
@@ -117,7 +116,7 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
}
@Override
- public void deleteByKey(K key, SonarSession session) {
+ public void deleteByKey(K key, DbSession session) {
session.enqueue(new IndexAction(this.getIndexName(),
IndexAction.Method.DELETE, key));
this.doDeleteByKey(key, session);
@@ -125,7 +124,7 @@ public abstract class BaseDao<E extends Dto<K>, K extends Serializable>
@Override
public void deleteByKey(K key) {
- SonarSession session = getMyBatis().openSession();
+ DbSession session = getMyBatis().openSession(false);
try {
this.doDeleteByKey(key, session);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/db/Dao.java b/sonar-core/src/main/java/org/sonar/core/db/Dao.java
index 96f7113936a..35526903da8 100644
--- a/sonar-core/src/main/java/org/sonar/core/db/Dao.java
+++ b/sonar-core/src/main/java/org/sonar/core/db/Dao.java
@@ -19,7 +19,7 @@
*/
package org.sonar.core.db;
-import org.sonar.core.persistence.SonarSession;
+import org.sonar.core.persistence.DbSession;
import java.io.Serializable;
@@ -29,19 +29,19 @@ public interface Dao<E extends Dto<K>, K extends Serializable> {
E update(E item);
- E update(E item, SonarSession session);
+ E update(E item, DbSession session);
E insert(E item);
- E insert(E item, SonarSession session);
+ E insert(E item, DbSession session);
void delete(E item);
- void delete(E item, SonarSession session);
+ void delete(E item, DbSession session);
void deleteByKey(K key);
- void deleteByKey(K key, SonarSession session);
+ void deleteByKey(K key, DbSession session);
Iterable<K> keysOfRowsUpdatedAfter(long timestamp);
}
diff --git a/sonar-core/src/main/java/org/sonar/core/duplication/DuplicationDao.java b/sonar-core/src/main/java/org/sonar/core/duplication/DuplicationDao.java
index 69884f12157..57887646ee6 100644
--- a/sonar-core/src/main/java/org/sonar/core/duplication/DuplicationDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/duplication/DuplicationDao.java
@@ -22,6 +22,7 @@ package org.sonar.core.duplication;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import java.util.Collection;
@@ -36,7 +37,7 @@ public class DuplicationDao implements BatchComponent, ServerComponent {
}
public List<DuplicationUnitDto> selectCandidates(int resourceSnapshotId, Integer lastSnapshotId, String language) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
DuplicationMapper mapper = session.getMapper(DuplicationMapper.class);
return mapper.selectCandidates(resourceSnapshotId, lastSnapshotId, language);
@@ -50,7 +51,7 @@ public class DuplicationDao implements BatchComponent, ServerComponent {
* Note that generated ids are not returned.
*/
public void insert(Collection<DuplicationUnitDto> units) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
DuplicationMapper mapper = session.getMapper(DuplicationMapper.class);
for (DuplicationUnitDto unit : units) {
diff --git a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java
index c2d7492fa1e..40b1740c9f3 100644
--- a/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/graph/jdbc/GraphDao.java
@@ -19,7 +19,7 @@
*/
package org.sonar.core.graph.jdbc;
-import org.apache.ibatis.session.SqlSession;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
public class GraphDao {
@@ -30,7 +30,7 @@ public class GraphDao {
}
public GraphDto selectBySnapshot(String perspectiveKey, long snapshotId) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
return mapper.selectBySnapshot(perspectiveKey, snapshotId);
@@ -41,7 +41,7 @@ public class GraphDao {
}
public GraphDto selectByComponent(String perspectiveKey, String componentKey) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class);
return mapper.selectByComponent(perspectiveKey, componentKey);
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanDao.java
index 6ae5a93b6ac..b0211fd7830 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanDao.java
@@ -44,7 +44,7 @@ public class ActionPlanDao implements BatchComponent, ServerComponent {
}
public void save(ActionPlanDto actionPlanDto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
session.getMapper(ActionPlanMapper.class).insert(actionPlanDto);
session.commit();
@@ -54,7 +54,7 @@ public class ActionPlanDao implements BatchComponent, ServerComponent {
}
public void update(ActionPlanDto actionPlanDto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
session.getMapper(ActionPlanMapper.class).update(actionPlanDto);
session.commit();
@@ -64,7 +64,7 @@ public class ActionPlanDao implements BatchComponent, ServerComponent {
}
public void delete(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
session.getMapper(ActionPlanMapper.class).delete(key);
session.commit();
@@ -74,7 +74,7 @@ public class ActionPlanDao implements BatchComponent, ServerComponent {
}
public ActionPlanDto findByKey(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ActionPlanMapper.class).findByKey(key);
} finally {
@@ -86,7 +86,7 @@ public class ActionPlanDao implements BatchComponent, ServerComponent {
if (keys.isEmpty()) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
List<ActionPlanDto> dtosList = newArrayList();
List<List<String>> keysPartition = Lists.partition(newArrayList(keys), 1000);
@@ -101,7 +101,7 @@ public class ActionPlanDao implements BatchComponent, ServerComponent {
}
public List<ActionPlanDto> findOpenByProjectId(Long projectId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ActionPlanMapper.class).findOpenByProjectId(projectId);
} finally {
@@ -110,7 +110,7 @@ public class ActionPlanDao implements BatchComponent, ServerComponent {
}
public List<ActionPlanDto> findByNameAndProjectId(String name, Long projectId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ActionPlanMapper.class).findByNameAndProjectId(name, projectId);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanStatsDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanStatsDao.java
index ccd43a48ed0..f32d2fc9750 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanStatsDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/ActionPlanStatsDao.java
@@ -39,7 +39,7 @@ public class ActionPlanStatsDao implements BatchComponent, ServerComponent {
}
public List<ActionPlanStatsDto> findByProjectId(Long projectId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ActionPlanStatsMapper.class).findByProjectId(projectId);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java
index 55035c0740c..458781bae75 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueChangeDao.java
@@ -56,7 +56,7 @@ public class IssueChangeDao implements BatchComponent, ServerComponent {
}
public List<FieldDiffs> selectChangelogByIssue(String issueKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
List<FieldDiffs> result = Lists.newArrayList();
for (IssueChangeDto dto : selectByIssuesAndType(session, Arrays.asList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE)) {
@@ -69,7 +69,7 @@ public class IssueChangeDao implements BatchComponent, ServerComponent {
}
public void selectChangelogOnNonClosedIssuesByModuleAndType(Integer componentId, ResultHandler handler) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
Map<String, Object> params = newHashMap();
params.put("componentId", componentId);
@@ -83,7 +83,7 @@ public class IssueChangeDao implements BatchComponent, ServerComponent {
@CheckForNull
public DefaultIssueComment selectCommentByKey(String commentKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
IssueChangeDto dto = mapper.selectByKeyAndType(commentKey, IssueChangeDto.TYPE_COMMENT);
@@ -109,7 +109,7 @@ public class IssueChangeDao implements BatchComponent, ServerComponent {
}
public boolean delete(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
int count = mapper.delete(key);
@@ -122,7 +122,7 @@ public class IssueChangeDao implements BatchComponent, ServerComponent {
}
public boolean update(IssueChangeDto change) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
IssueChangeMapper mapper = session.getMapper(IssueChangeMapper.class);
int count = mapper.update(change);
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java
index 486f36e76a3..f5662628586 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java
@@ -51,7 +51,7 @@ public class IssueDao implements BatchComponent, ServerComponent {
@CheckForNull
public IssueDto selectByKey(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
IssueMapper mapper = session.getMapper(IssueMapper.class);
return mapper.selectByKey(key);
@@ -61,7 +61,7 @@ public class IssueDao implements BatchComponent, ServerComponent {
}
public void selectNonClosedIssuesByModule(int componentId, ResultHandler handler) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
session.select("org.sonar.core.issue.db.IssueMapper.selectNonClosedIssuesByModule", componentId, handler);
@@ -72,7 +72,7 @@ public class IssueDao implements BatchComponent, ServerComponent {
@VisibleForTesting
List<IssueDto> selectIssueIds(IssueQuery query, @Nullable Integer userId, Integer maxResult) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectIssueIds(query, userId, maxResult, session);
} finally {
@@ -82,7 +82,7 @@ public class IssueDao implements BatchComponent, ServerComponent {
@VisibleForTesting
List<IssueDto> selectIssueIds(IssueQuery query) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectIssueIds(query, null, Integer.MAX_VALUE, session);
} finally {
@@ -103,7 +103,7 @@ public class IssueDao implements BatchComponent, ServerComponent {
}
public List<IssueDto> selectIssues(IssueQuery query) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectIssues(query, null, session);
} finally {
@@ -118,7 +118,7 @@ public class IssueDao implements BatchComponent, ServerComponent {
@VisibleForTesting
List<IssueDto> selectByIds(Collection<Long> ids) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByIds(ids, session);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java
index d6cad077835..a2d9d443353 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterDao.java
@@ -42,7 +42,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
@CheckForNull
public IssueFilterDto selectById(Long id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
session.getMapper(IssueFilterMapper.class);
return getMapper(session).selectById(id);
@@ -52,7 +52,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
public List<IssueFilterDto> selectByUser(String user) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getMapper(session).selectByUser(user);
} finally {
@@ -61,7 +61,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
public List<IssueFilterDto> selectFavoriteFiltersByUser(String user) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getMapper(session).selectFavoriteFiltersByUser(user);
} finally {
@@ -70,7 +70,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
public List<IssueFilterDto> selectSharedFilters() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getMapper(session).selectSharedFilters();
} finally {
@@ -79,7 +79,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
public void insert(IssueFilterDto filter) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
getMapper(session).insert(filter);
session.commit();
@@ -89,7 +89,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
public void update(IssueFilterDto filter) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
getMapper(session).update(filter);
session.commit();
@@ -99,7 +99,7 @@ public class IssueFilterDao implements BatchComponent, ServerComponent {
}
public void delete(Long id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
getMapper(session).delete(id);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java
index adc0907c52d..3221b4ff31e 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueFilterFavouriteDao.java
@@ -39,7 +39,7 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent
}
public IssueFilterFavouriteDto selectById(Long id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getMapper(session).selectById(id);
} finally {
@@ -48,7 +48,7 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent
}
public List<IssueFilterFavouriteDto> selectByFilterId(Long filterId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getMapper(session).selectByFilterId(filterId);
} finally {
@@ -57,7 +57,7 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent
}
public void insert(IssueFilterFavouriteDto filter) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
getMapper(session).insert(filter);
session.commit();
@@ -67,7 +67,7 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent
}
public void delete(Long id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
getMapper(session).delete(id);
session.commit();
@@ -77,7 +77,7 @@ public class IssueFilterFavouriteDao implements BatchComponent, ServerComponent
}
public void deleteByFilterId(Long filterId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
getMapper(session).deleteByFilterId(filterId);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStatsDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStatsDao.java
index d2ab20a1699..fc5769903e2 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStatsDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStatsDao.java
@@ -41,7 +41,7 @@ public class IssueStatsDao implements ServerComponent {
}
public List<Object> selectIssuesColumn(IssueQuery query, String column, @Nullable Integer userId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
IssueStatsMapper mapper = session.getMapper(IssueStatsMapper.class);
return mapper.selectIssuesColumn(query, column, query.componentRoots(), userId, query.requiredRole());
diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java
index a52f728a5df..0de970e0f8d 100644
--- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java
+++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueStorage.java
@@ -29,6 +29,7 @@ import org.sonar.api.issue.internal.FieldDiffs;
import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RuleFinder;
import org.sonar.core.persistence.BatchSession;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import java.util.Arrays;
@@ -69,7 +70,7 @@ public abstract class IssueStorage {
private List<DefaultIssue> batchInsert(Iterable<DefaultIssue> issues, Date now) {
List<DefaultIssue> toBeUpdated = Lists.newArrayList();
- SqlSession batchSession = mybatis.openBatchSession();
+ DbSession batchSession = mybatis.openSession(true);
int count = 0;
IssueMapper issueMapper = batchSession.getMapper(IssueMapper.class);
IssueChangeMapper issueChangeMapper = batchSession.getMapper(IssueChangeMapper.class);
@@ -103,7 +104,7 @@ public abstract class IssueStorage {
private void update(List<DefaultIssue> toBeUpdated, Date now) {
if (!toBeUpdated.isEmpty()) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
IssueMapper issueMapper = session.getMapper(IssueMapper.class);
IssueChangeMapper issueChangeMapper = session.getMapper(IssueChangeMapper.class);
diff --git a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java
index 124b68a556a..713280e3022 100644
--- a/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java
+++ b/sonar-core/src/main/java/org/sonar/core/measure/MeasureFilterExecutor.java
@@ -53,7 +53,7 @@ public class MeasureFilterExecutor implements ServerComponent {
SqlSession session = null;
Connection connection = null;
try {
- session = mybatis.openSession();
+ session = mybatis.openSession(false);
prepareContext(context, filter, session);
if (isValid(filter, context)) {
diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDao.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDao.java
index 62cf8ebaf6d..45aa4db5acd 100644
--- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureDataDao.java
@@ -33,7 +33,7 @@ public class MeasureDataDao implements ServerComponent {
}
public MeasureDataDto findByComponentKeyAndMetricKey(String componentKey, String metricKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
MeasureDataMapper mapper = session.getMapper(MeasureDataMapper.class);
return mapper.findByComponentKeyAndMetricKey(componentKey, metricKey);
diff --git a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureFilterDao.java b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureFilterDao.java
index 28f54a5af5f..50a26d25477 100644
--- a/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureFilterDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/measure/db/MeasureFilterDao.java
@@ -35,7 +35,7 @@ public class MeasureFilterDao implements BatchComponent, ServerComponent {
}
public MeasureFilterDto findSystemFilterByName(String name) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
MeasureFilterMapper mapper = session.getMapper(MeasureFilterMapper.class);
return mapper.findSystemFilterByName(name);
@@ -45,7 +45,7 @@ public class MeasureFilterDao implements BatchComponent, ServerComponent {
}
public void insert(MeasureFilterDto filter) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
MeasureFilterMapper mapper = session.getMapper(MeasureFilterMapper.class);
try {
mapper.insert(filter);
diff --git a/sonar-core/src/main/java/org/sonar/core/notification/db/NotificationQueueDao.java b/sonar-core/src/main/java/org/sonar/core/notification/db/NotificationQueueDao.java
index 988fc68115e..bd90804092d 100644
--- a/sonar-core/src/main/java/org/sonar/core/notification/db/NotificationQueueDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/notification/db/NotificationQueueDao.java
@@ -23,6 +23,7 @@ package org.sonar.core.notification.db;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import java.util.Collections;
@@ -40,7 +41,7 @@ public class NotificationQueueDao implements BatchComponent, ServerComponent {
}
public void insert(List<NotificationQueueDto> dtos) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
for (NotificationQueueDto dto : dtos) {
session.getMapper(NotificationQueueMapper.class).insert(dto);
@@ -52,7 +53,7 @@ public class NotificationQueueDao implements BatchComponent, ServerComponent {
}
public void delete(List<NotificationQueueDto> dtos) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
for (NotificationQueueDto dto : dtos) {
session.getMapper(NotificationQueueMapper.class).delete(dto.getId());
@@ -67,7 +68,7 @@ public class NotificationQueueDao implements BatchComponent, ServerComponent {
if (count < 1) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(NotificationQueueMapper.class).findOldest(count);
} finally {
@@ -76,7 +77,7 @@ public class NotificationQueueDao implements BatchComponent, ServerComponent {
}
public long count() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(NotificationQueueMapper.class).count();
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java
index 6a36467e75a..b3071be9403 100644
--- a/sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionDao.java
@@ -48,7 +48,7 @@ public class PermissionDao implements ServerComponent {
* @return a paginated list of users.
*/
public List<UserWithPermissionDto> selectUsers(PermissionQuery query, @Nullable Long componentId, int offset, int limit) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
Map<String, Object> params = newHashMap();
params.put(QUERY_PARAMETER, query);
@@ -70,7 +70,7 @@ public class PermissionDao implements ServerComponent {
* @return a non paginated list of groups.
*/
public List<GroupWithPermissionDto> selectGroups(PermissionQuery query, @Nullable Long componentId) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
Map<String, Object> params = newHashMap();
params.put(QUERY_PARAMETER, query);
diff --git a/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java
index e8e324a486d..9c2f39c4fcf 100644
--- a/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java
+++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionFacade.java
@@ -172,7 +172,7 @@ public class PermissionFacade implements TaskComponent, ServerComponent {
public void applyPermissionTemplate(String templateKey, Long resourceId) {
PermissionTemplateDto permissionTemplate = getPermissionTemplateWithPermissions(templateKey);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
removeAllPermissions(resourceId, session);
List<PermissionTemplateUserDto> usersPermissions = permissionTemplate.getUsersPermissions();
diff --git a/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java
index 038fb0e3877..12de7d95c95 100644
--- a/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/permission/PermissionTemplateDao.java
@@ -59,7 +59,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
* @return a paginated list of users.
*/
public List<UserWithPermissionDto> selectUsers(PermissionQuery query, Long templateId, int offset, int limit) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
Map<String, Object> params = newHashMap();
params.put(QUERY_PARAMETER, query);
@@ -81,7 +81,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
* @return a non paginated list of groups.
*/
public List<GroupWithPermissionDto> selectGroups(PermissionQuery query, Long templateId) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
Map<String, Object> params = newHashMap();
params.put(QUERY_PARAMETER, query);
@@ -95,7 +95,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
@CheckForNull
public PermissionTemplateDto selectTemplateByKey(String templateKey) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
return mapper.selectByKey(templateKey);
@@ -107,7 +107,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
@CheckForNull
public PermissionTemplateDto selectPermissionTemplate(String templateKey) {
PermissionTemplateDto permissionTemplate = null;
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
permissionTemplate = mapper.selectByKey(templateKey);
@@ -126,7 +126,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
}
public List<PermissionTemplateDto> selectAllPermissionTemplates() {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return session.selectList("selectAllPermissionTemplates");
} finally {
@@ -143,7 +143,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
.setKeyPattern(keyPattern)
.setCreatedAt(creationDate)
.setUpdatedAt(creationDate);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
mapper.insert(permissionTemplate);
@@ -155,7 +155,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
}
public void deletePermissionTemplate(Long templateId) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
mapper.deleteUsersPermissions(templateId);
@@ -174,7 +174,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
.setDescription(description)
.setKeyPattern(keyPattern)
.setUpdatedAt(now());
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
mapper.update(permissionTemplate);
@@ -191,7 +191,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
.setPermission(permission)
.setCreatedAt(now())
.setUpdatedAt(now());
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
mapper.insertUserPermission(permissionTemplateUser);
@@ -206,7 +206,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
.setTemplateId(templateId)
.setPermission(permission)
.setUserId(userId);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
mapper.deleteUserPermission(permissionTemplateUser);
@@ -223,7 +223,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
.setGroupId(groupId)
.setCreatedAt(now())
.setUpdatedAt(now());
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
mapper.insertGroupPermission(permissionTemplateGroup);
@@ -238,7 +238,7 @@ public class PermissionTemplateDao implements TaskComponent, ServerComponent {
.setTemplateId(templateId)
.setPermission(permission)
.setGroupId(groupId);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = session.getMapper(PermissionTemplateMapper.class);
mapper.deleteGroupPermission(permissionTemplateGroup);
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java b/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java
index bc456083ebe..a12942e13a9 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java
@@ -33,7 +33,7 @@ import java.sql.Connection;
import java.util.List;
import java.util.Map;
-public class BatchSession extends SonarSession {
+public class BatchSession extends DbSession {
public static final int MAX_BATCH_SIZE = 250;
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
index 0bec63db4ee..ddda96bf237 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DatabaseVersion.java
@@ -104,7 +104,7 @@ public class DatabaseVersion implements BatchComponent, ServerComponent {
}
public Integer getVersion() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
List<Integer> versions = session.getMapper(SchemaMigrationMapper.class).selectVersions();
if (!versions.isEmpty()) {
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/SonarSession.java b/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java
index af135e9c0fb..ea729a2f666 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/SonarSession.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/DbSession.java
@@ -33,17 +33,17 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-public class SonarSession implements SqlSession {
+public class DbSession implements SqlSession {
- private List<IndexAction> actions;
+ private List<IndexAction<?>> actions;
private WorkQueue queue;
private SqlSession session;
- SonarSession(WorkQueue queue, SqlSession session) {
+ DbSession(WorkQueue queue, SqlSession session) {
this.session = session;
this.queue = queue;
- this.actions = new ArrayList<IndexAction>();
+ this.actions = new ArrayList<IndexAction<?>>();
}
public void enqueue(IndexAction action) {
@@ -53,13 +53,13 @@ public class SonarSession implements SqlSession {
@Override
public void commit() {
session.commit();
- queue.enqueue(actions.toArray(new IndexAction[0]));
+ queue.enqueue(actions);
}
@Override
public void commit(boolean force) {
session.commit(force);
- queue.enqueue(actions.toArray(new IndexAction[0]));
+ queue.enqueue(actions);
}
/**
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
index 05d92e98c03..e113adbe9ab 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/MyBatis.java
@@ -236,14 +236,32 @@ public class MyBatis implements BatchComponent, ServerComponent {
return sessionFactory;
}
- public SonarSession openSession() {
- SqlSession session = sessionFactory.openSession(ExecutorType.REUSE);
- return new SonarSession(queue, session);
+ /**
+ * @deprecated since 4.4. Replaced by <code>openSession(false)</code>.
+ */
+ @Deprecated
+ public SqlSession openSession() {
+ return openSession(false);
}
+ /**
+ * @deprecated since 4.4. Replaced by <code>openSession(true)</code>.
+ */
+ @Deprecated
public BatchSession openBatchSession() {
- SqlSession session = sessionFactory.openSession(ExecutorType.BATCH);
- return new BatchSession(queue, session);
+ return (BatchSession) openSession(true);
+ }
+
+ /**
+ * @since 4.4
+ */
+ public DbSession openSession(boolean batch) {
+ if (batch) {
+ SqlSession session = sessionFactory.openSession(ExecutorType.BATCH);
+ return new BatchSession(queue, session);
+ }
+ SqlSession session = sessionFactory.openSession(ExecutorType.REUSE);
+ return new DbSession(queue, session);
}
public static void closeQuietly(SqlSession session) {
diff --git a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java
index fd1c8da6c66..e995a5ed506 100644
--- a/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDao.java
@@ -43,7 +43,7 @@ public class SemaphoreDao {
Preconditions.checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
Preconditions.checkArgument(maxAgeInSeconds >= 0, "Semaphore max age must be positive: " + maxAgeInSeconds);
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
Date now = mapper.now();
@@ -63,7 +63,7 @@ public class SemaphoreDao {
public Semaphores.Semaphore acquire(String name) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
Date now = mapper.now();
@@ -82,7 +82,7 @@ public class SemaphoreDao {
public void update(Semaphores.Semaphore semaphore) {
Preconditions.checkArgument(semaphore != null, "Semaphore must not be null");
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
SemaphoreMapper mapper = session.getMapper(SemaphoreMapper.class);
mapper.update(semaphore.getName());
@@ -94,7 +94,7 @@ public class SemaphoreDao {
public void release(String name) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(name), SEMAPHORE_NAME_MUST_NOT_BE_EMPTY);
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
session.getMapper(SemaphoreMapper.class).release(name);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/preview/PreviewCache.java b/sonar-core/src/main/java/org/sonar/core/preview/PreviewCache.java
index c93601553bb..57c2adeae9d 100644
--- a/sonar-core/src/main/java/org/sonar/core/preview/PreviewCache.java
+++ b/sonar-core/src/main/java/org/sonar/core/preview/PreviewCache.java
@@ -193,7 +193,7 @@ public class PreviewCache implements ServerExtension {
}
public void reportGlobalModification() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
reportGlobalModification(session);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java
index d4e5bc3a4d6..521077c4bf1 100644
--- a/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/properties/PropertiesDao.java
@@ -25,6 +25,7 @@ import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.BatchComponent;
import org.sonar.api.ServerComponent;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import javax.annotation.Nullable;
@@ -50,7 +51,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
* @return the list of logins (maybe be empty - obviously)
*/
public List<String> findUsersForNotification(String notificationDispatcherKey, String notificationChannelKey, @Nullable Long resourceId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
return mapper.findUsersForNotification(NOTIFICATION_PREFIX + notificationDispatcherKey + "." + notificationChannelKey, resourceId);
@@ -60,7 +61,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public List<String> findNotificationSubscribers(String notificationDispatcherKey, String notificationChannelKey, @Nullable String componentKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
return mapper.findNotificationSubscribers(NOTIFICATION_PREFIX + notificationDispatcherKey + "." + notificationChannelKey, componentKey);
@@ -70,7 +71,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public List<PropertyDto> selectGlobalProperties() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
return mapper.selectGlobalProperties();
@@ -80,7 +81,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public PropertyDto selectGlobalProperty(String propertyKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
return mapper.selectByKey(new PropertyDto().setKey(propertyKey));
@@ -90,7 +91,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public List<PropertyDto> selectProjectProperties(String resourceKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
return mapper.selectProjectProperties(resourceKey);
@@ -100,7 +101,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public PropertyDto selectProjectProperty(long resourceId, String propertyKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
return mapper.selectByKey(new PropertyDto().setKey(propertyKey).setResourceId(resourceId));
@@ -121,7 +122,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public void setProperty(PropertyDto property) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
setProperty(property, session);
session.commit();
@@ -131,7 +132,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public void deleteProjectProperty(String key, Long projectId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteProjectProperty(key, projectId, session);
session.commit();
@@ -151,7 +152,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public void deleteProjectProperties(String key, String value) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteProjectProperties(key, value, session);
session.commit();
@@ -161,7 +162,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public void deleteGlobalProperties() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
mapper.deleteGlobalProperties();
@@ -178,7 +179,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public void deleteGlobalProperty(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteGlobalProperty(key, session);
session.commit();
@@ -188,7 +189,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public void deleteAllProperties(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
mapper.deleteAllProperties(key);
@@ -200,7 +201,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
}
public void saveGlobalProperties(Map<String, String> properties) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
for (Map.Entry<String, String> entry : properties.entrySet()) {
@@ -221,7 +222,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
Preconditions.checkArgument(!Strings.isNullOrEmpty(newKey), "New property key must not be empty");
if (!newKey.equals(oldKey)) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
PropertiesMapper mapper = session.getMapper(PropertiesMapper.class);
try {
mapper.renamePropertyKey(oldKey, newKey);
@@ -237,7 +238,7 @@ public class PropertiesDao implements BatchComponent, ServerComponent {
* Update all properties (global and projects ones) with a given key and value to a new value
*/
public void updateProperties(String key, String oldValue, String newValue) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
updateProperties(key, oldValue, newValue, session);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
index 5777908166b..10dd7a2693d 100644
--- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java
@@ -26,6 +26,7 @@ import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import org.sonar.core.resource.ResourceDao;
import org.sonar.core.resource.ResourceDto;
@@ -51,7 +52,7 @@ public class PurgeDao {
}
public PurgeDao purge(PurgeConfiguration conf) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
PurgeMapper mapper = session.getMapper(PurgeMapper.class);
PurgeCommands commands = new PurgeCommands(session, mapper, profiler);
try {
@@ -135,7 +136,7 @@ public class PurgeDao {
}
public List<PurgeableSnapshotDto> selectPurgeableSnapshots(long resourceId) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
PurgeMapper mapper = session.getMapper(PurgeMapper.class);
List<PurgeableSnapshotDto> result = Lists.newArrayList();
@@ -150,7 +151,7 @@ public class PurgeDao {
}
public PurgeDao deleteResourceTree(long rootProjectId) {
- final SqlSession session = mybatis.openBatchSession();
+ final DbSession session = mybatis.openSession(true);
final PurgeMapper mapper = session.getMapper(PurgeMapper.class);
try {
deleteProject(rootProjectId, mapper, new PurgeCommands(session, profiler));
@@ -178,7 +179,7 @@ public class PurgeDao {
}
public PurgeDao deleteSnapshots(PurgeSnapshotQuery query) {
- final SqlSession session = mybatis.openBatchSession();
+ final DbSession session = mybatis.openSession(true);
try {
new PurgeCommands(session, profiler).deleteSnapshots(query);
return this;
diff --git a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/ProjectQgateAssociationDao.java b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/ProjectQgateAssociationDao.java
index e268ab4cd52..f8e64eb715c 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/ProjectQgateAssociationDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/ProjectQgateAssociationDao.java
@@ -38,7 +38,7 @@ public class ProjectQgateAssociationDao {
}
public List<ProjectQgateAssociationDto> selectProjects(ProjectQgateAssociationQuery query, Long gateId, int offset, int limit) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
Map<String, Object> params = ImmutableMap.of("query", query, "gateId", gateId.toString());
return session.selectList("org.sonar.core.qualitygate.db.ProjectQgateAssociationMapper.selectProjects", params, new RowBounds(offset, limit));
diff --git a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDao.java b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDao.java
index 280cf141865..a634f15bf61 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateConditionDao.java
@@ -37,7 +37,7 @@ public class QualityGateConditionDao {
}
public void insert(QualityGateConditionDto newQualityGate) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
insert(newQualityGate, session);
session.commit();
@@ -51,7 +51,7 @@ public class QualityGateConditionDao {
}
public Collection<QualityGateConditionDto> selectForQualityGate(long qGateId) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectForQualityGate(qGateId, session);
} finally {
@@ -64,7 +64,7 @@ public class QualityGateConditionDao {
}
public QualityGateConditionDto selectById(long id) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectById(id, session);
} finally {
@@ -77,7 +77,7 @@ public class QualityGateConditionDao {
}
public void delete(QualityGateConditionDto qGate) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
delete(qGate, session);
session.commit();
@@ -91,7 +91,7 @@ public class QualityGateConditionDao {
}
public void update(QualityGateConditionDto qGate) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
update(qGate, session);
session.commit();
@@ -105,7 +105,7 @@ public class QualityGateConditionDao {
}
public void deleteConditionsWithInvalidMetrics() {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
deleteConditionsWithInvalidMetrics(session);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateDao.java b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateDao.java
index fa6c0a7f9a7..0cc6d669cab 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualitygate/db/QualityGateDao.java
@@ -37,7 +37,7 @@ public class QualityGateDao {
}
public void insert(QualityGateDto newQualityGate) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
insert(newQualityGate, session);
session.commit();
@@ -51,7 +51,7 @@ public class QualityGateDao {
}
public Collection<QualityGateDto> selectAll() {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectAll(session);
} finally {
@@ -64,7 +64,7 @@ public class QualityGateDao {
}
public QualityGateDto selectByName(String name) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectByName(name, session);
} finally {
@@ -77,7 +77,7 @@ public class QualityGateDao {
}
public QualityGateDto selectById(long id) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectById(id, session);
} finally {
@@ -90,7 +90,7 @@ public class QualityGateDao {
}
public void delete(QualityGateDto qGate) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
delete(qGate, session);
session.commit();
@@ -104,7 +104,7 @@ public class QualityGateDao {
}
public void update(QualityGateDto qGate) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
update(qGate, session);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java
index 46dfae1d38e..f7069f58ced 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/ActiveRuleDao.java
@@ -46,7 +46,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void insert(ActiveRuleDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insert(dto, session);
session.commit();
@@ -60,7 +60,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void update(ActiveRuleDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
update(dto, session);
session.commit();
@@ -74,7 +74,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void delete(int activeRuleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
delete(activeRuleId, session);
session.commit();
@@ -88,7 +88,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void deleteFromRule(int ruleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteFromRule(ruleId, session);
session.commit();
@@ -102,7 +102,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void deleteFromProfile(int profileId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteFromProfile(profileId, session);
session.commit();
@@ -112,7 +112,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleDto> selectByIds(List<Integer> ids) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByIds(ids, session);
} finally {
@@ -134,7 +134,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleDto> selectAll() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectAll(session);
} finally {
@@ -147,7 +147,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleDto> selectByRuleId(int ruleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByRuleId(ruleId, session);
} finally {
@@ -160,7 +160,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleDto> selectByProfileId(int profileId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByProfileId(profileId, session);
} finally {
@@ -175,7 +175,7 @@ public class ActiveRuleDao implements ServerComponent {
@CheckForNull
public ActiveRuleDto selectById(int id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectById(id, session);
} finally {
@@ -190,7 +190,7 @@ public class ActiveRuleDao implements ServerComponent {
@CheckForNull
public ActiveRuleDto selectByProfileAndRule(int profileId, int ruleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByProfileAndRule(profileId, ruleId, session);
} finally {
@@ -208,7 +208,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void insert(ActiveRuleParamDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insert(dto, session);
session.commit();
@@ -222,7 +222,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void update(ActiveRuleParamDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
update(dto, session);
session.commit();
@@ -237,7 +237,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void deleteParameter(int activeRuleParamId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteParameter(activeRuleParamId, session);
session.commit();
@@ -251,7 +251,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void deleteParameters(int activeRuleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteParameters(activeRuleId, session);
session.commit();
@@ -265,7 +265,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public void deleteParametersFromProfile(int profileId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteParametersFromProfile(profileId, session);
session.commit();
@@ -279,7 +279,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public ActiveRuleParamDto selectParamById(Integer activeRuleParamId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ActiveRuleMapper.class).selectParamById(activeRuleParamId);
} finally {
@@ -288,7 +288,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public ActiveRuleParamDto selectParamByActiveRuleAndKey(int activeRuleId, String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectParamByActiveRuleAndKey(activeRuleId, key, session);
} finally {
@@ -301,7 +301,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleParamDto> selectParamsByActiveRuleId(int activeRuleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectParamsByActiveRuleId(activeRuleId, session);
} finally {
@@ -314,7 +314,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleParamDto> selectParamsByActiveRuleIds(List<Integer> activeRuleIds) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectParamsByActiveRuleIds(activeRuleIds, session);
} finally {
@@ -336,7 +336,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleParamDto> selectAllParams() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectAllParams(session);
} finally {
@@ -349,7 +349,7 @@ public class ActiveRuleDao implements ServerComponent {
}
public List<ActiveRuleParamDto> selectParamsByProfileId(int profileId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ActiveRuleMapper.class).selectParamsByProfileId(profileId);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java
index be550fdc706..5cdf6b1b965 100644
--- a/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/qualityprofile/db/QualityProfileDao.java
@@ -42,7 +42,7 @@ public class QualityProfileDao implements ServerComponent {
}
public void insert(QualityProfileDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insert(dto, session);
session.commit();
@@ -56,7 +56,7 @@ public class QualityProfileDao implements ServerComponent {
}
public void update(QualityProfileDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
update(dto, session);
session.commit();
@@ -70,7 +70,7 @@ public class QualityProfileDao implements ServerComponent {
}
public void delete(int id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
delete(id, session);
session.commit();
@@ -80,7 +80,7 @@ public class QualityProfileDao implements ServerComponent {
}
public List<QualityProfileDto> selectAll() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(QualityProfileMapper.class).selectAll();
} finally {
@@ -93,7 +93,7 @@ public class QualityProfileDao implements ServerComponent {
}
public QualityProfileDto selectDefaultProfile(String language, String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectDefaultProfile(language, key, session);
} finally {
@@ -102,7 +102,7 @@ public class QualityProfileDao implements ServerComponent {
}
public QualityProfileDto selectByProjectAndLanguage(long projectId, String language, String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(QualityProfileMapper.class).selectByProjectAndLanguage(projectId, language, key);
} finally {
@@ -111,7 +111,7 @@ public class QualityProfileDao implements ServerComponent {
}
public List<QualityProfileDto> selectByLanguage(String language) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(QualityProfileMapper.class).selectByLanguage(language);
} finally {
@@ -126,7 +126,7 @@ public class QualityProfileDao implements ServerComponent {
@CheckForNull
public QualityProfileDto selectById(int id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectById(id, session);
} finally {
@@ -141,7 +141,7 @@ public class QualityProfileDao implements ServerComponent {
@CheckForNull
public QualityProfileDto selectParent(int childId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectParent(childId, session);
} finally {
@@ -154,7 +154,7 @@ public class QualityProfileDao implements ServerComponent {
}
public List<QualityProfileDto> selectChildren(String name, String language) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectChildren(name, language, session);
} finally {
@@ -167,7 +167,7 @@ public class QualityProfileDao implements ServerComponent {
}
public int countChildren(String name, String language) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return countChildren(name, language, session);
} finally {
@@ -180,7 +180,7 @@ public class QualityProfileDao implements ServerComponent {
}
public QualityProfileDto selectByNameAndLanguage(String name, String language) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByNameAndLanguage(name, language, session);
} finally {
@@ -189,7 +189,7 @@ public class QualityProfileDao implements ServerComponent {
}
public List<ComponentDto> selectProjects(String propertyKey, String propertyValue) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectProjects(propertyKey, propertyValue, session);
} finally {
@@ -202,7 +202,7 @@ public class QualityProfileDao implements ServerComponent {
}
public int countProjects(String propertyKey, String propertyValue) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(QualityProfileMapper.class).countProjects(propertyKey, propertyValue);
} finally {
@@ -211,7 +211,7 @@ public class QualityProfileDao implements ServerComponent {
}
public void updateUsedColumn(int profileId, boolean used) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
session.getMapper(QualityProfileMapper.class).updatedUsedColumn(profileId, used);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java b/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java
index 146cfcf3634..0b167cfe728 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/DefaultResourcePermissions.java
@@ -50,7 +50,7 @@ public class DefaultResourcePermissions implements ResourcePermissions {
public void grantUserRole(Resource resource, String login, String role) {
if (resource.getId() != null) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
UserDto user = session.getMapper(UserMapper.class).selectUserByLogin(login);
if (user != null) {
@@ -66,7 +66,7 @@ public class DefaultResourcePermissions implements ResourcePermissions {
public void grantGroupRole(Resource resource, String groupName, String role) {
if (resource.getId() != null) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
permissionFacade.deleteGroupPermission(Long.valueOf(resource.getId()), groupName, role, session);
permissionFacade.insertGroupPermission(Long.valueOf(resource.getId()), groupName, role, session);
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
index f68ebc61fb5..22582dc158f 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceDao.java
@@ -45,7 +45,7 @@ public class ResourceDao {
}
public List<ResourceDto> getResources(ResourceQuery query) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ResourceMapper.class).selectResources(query);
} finally {
@@ -63,7 +63,7 @@ public class ResourceDao {
*/
@CheckForNull
public ResourceDto getResource(ResourceQuery query) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getResource(query, session);
} finally {
@@ -81,7 +81,7 @@ public class ResourceDao {
}
public List<Long> getResourceIds(ResourceQuery query) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ResourceMapper.class).selectResourceIds(query);
} finally {
@@ -90,7 +90,7 @@ public class ResourceDao {
}
public ResourceDto getResource(long projectId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getResource(projectId, session);
} finally {
@@ -111,7 +111,7 @@ public class ResourceDao {
}
public List<ResourceDto> getDescendantProjects(long projectId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getDescendantProjects(projectId, session);
} finally {
@@ -135,7 +135,7 @@ public class ResourceDao {
}
public ResourceDao insertOrUpdate(ResourceDto... resources) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
ResourceMapper mapper = session.getMapper(ResourceMapper.class);
try {
for (ResourceDto resource : resources) {
@@ -157,7 +157,7 @@ public class ResourceDao {
if (ids.isEmpty()) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
List<ComponentDto> components = newArrayList();
List<List<Long>> partitionList = Lists.partition(newArrayList(ids), 1000);
@@ -179,7 +179,7 @@ public class ResourceDao {
@CheckForNull
public Component findById(Long id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return findById(id, session);
} finally {
@@ -197,7 +197,7 @@ public class ResourceDao {
if (componentRootKeys.isEmpty()) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ResourceMapper.class).selectAuthorizedChildrenComponentIds(componentRootKeys, userId, role);
} finally {
@@ -207,7 +207,7 @@ public class ResourceDao {
@CheckForNull
public ResourceDto getRootProjectByComponentKey(String componentKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ResourceMapper.class).selectRootProjectByComponentKey(componentKey);
} finally {
@@ -217,7 +217,7 @@ public class ResourceDao {
@CheckForNull
public ResourceDto getRootProjectByComponentId(Long componentId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ResourceMapper.class).selectRootProjectByComponentId(componentId);
} finally {
@@ -229,7 +229,7 @@ public class ResourceDao {
if (qualifiers.isEmpty()) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return toComponents(session.getMapper(ResourceMapper.class).selectProjectsByQualifiers(qualifiers));
} finally {
@@ -244,7 +244,7 @@ public class ResourceDao {
if (qualifiers.isEmpty()) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return toComponents(session.getMapper(ResourceMapper.class).selectProjectsIncludingNotCompletedOnesByQualifiers(qualifiers));
} finally {
@@ -262,7 +262,7 @@ public class ResourceDao {
if (qualifiers.isEmpty()) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return toComponents(session.getMapper(ResourceMapper.class).selectGhostsProjects(qualifiers));
} finally {
@@ -277,7 +277,7 @@ public class ResourceDao {
if (qualifiers.isEmpty()) {
return Collections.emptyList();
}
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ResourceMapper.class).selectProvisionedProjects(qualifiers);
} finally {
@@ -289,7 +289,7 @@ public class ResourceDao {
* Return provisioned project with given key
*/
public ResourceDto selectProvisionedProject(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return session.getMapper(ResourceMapper.class).selectProvisionedProject(key);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java
index 37c119504b8..c040bac2ec2 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceIndexerDao.java
@@ -25,6 +25,7 @@ import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.SqlSession;
import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Scopes;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
public class ResourceIndexerDao {
@@ -50,7 +51,7 @@ public class ResourceIndexerDao {
* This method is reentrant. It can be executed even if the project is already indexed.
*/
public ResourceIndexerDao indexProject(final int rootProjectId) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
ResourceIndexerMapper mapper = session.getMapper(ResourceIndexerMapper.class);
doIndexProject(rootProjectId, session, mapper);
@@ -66,7 +67,7 @@ public class ResourceIndexerDao {
* This method is reentrant. It can be executed even if some projects are already indexed.
*/
public ResourceIndexerDao indexProjects() {
- final SqlSession session = mybatis.openBatchSession();
+ final DbSession session = mybatis.openSession(true);
try {
final ResourceIndexerMapper mapper = session.getMapper(ResourceIndexerMapper.class);
session.select("org.sonar.core.resource.ResourceIndexerMapper.selectRootProjectIds", /* workaround to get booleans */ResourceIndexerQuery.create(), new ResultHandler() {
@@ -125,7 +126,7 @@ public class ResourceIndexerDao {
public boolean indexResource(long id) {
boolean indexed = false;
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
ResourceIndexerMapper mapper = session.getMapper(ResourceIndexerMapper.class);
ResourceDto resource = mapper.selectResourceToIndex(id);
@@ -144,7 +145,7 @@ public class ResourceIndexerDao {
public boolean indexResource(int id, String name, String qualifier, int rootId) {
boolean indexed = false;
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
ResourceIndexerMapper mapper = session.getMapper(ResourceIndexerMapper.class);
try {
indexed = indexResource(id, name, qualifier, rootId, session, mapper);
diff --git a/sonar-core/src/main/java/org/sonar/core/resource/ResourceKeyUpdaterDao.java b/sonar-core/src/main/java/org/sonar/core/resource/ResourceKeyUpdaterDao.java
index c4ea0c5ea75..06a202424dd 100644
--- a/sonar-core/src/main/java/org/sonar/core/resource/ResourceKeyUpdaterDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/resource/ResourceKeyUpdaterDao.java
@@ -24,6 +24,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.SqlSession;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import java.util.Collection;
@@ -44,7 +45,7 @@ public class ResourceKeyUpdaterDao {
}
public void updateKey(long projectId, String newKey) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class);
try {
if (mapper.countResourceByKey(newKey) > 0) {
@@ -67,7 +68,7 @@ public class ResourceKeyUpdaterDao {
}
public Map<String, String> checkModuleKeysBeforeRenaming(long projectId, String stringToReplace, String replacementString) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class);
Map<String, String> result = Maps.newHashMap();
try {
@@ -87,7 +88,7 @@ public class ResourceKeyUpdaterDao {
}
public void bulkUpdateKey(long projectId, String stringToReplace, String replacementString) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
ResourceKeyUpdaterMapper mapper = session.getMapper(ResourceKeyUpdaterMapper.class);
try {
// must SELECT first everything
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java
index 9a64d118ed5..098410292e1 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleDao.java
@@ -28,8 +28,8 @@ import org.sonar.api.ServerComponent;
import org.sonar.api.rule.RuleKey;
import org.sonar.core.db.BaseDao;
import org.sonar.core.db.UnsuportedException;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import javax.annotation.CheckForNull;
import java.sql.Timestamp;
@@ -80,7 +80,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public List<RuleDto> selectAll() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectAll(session);
} finally {
@@ -93,7 +93,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public List<RuleDto> selectEnablesAndNonManual() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectEnablesAndNonManual(session);
} finally {
@@ -110,7 +110,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public List<RuleDto> selectBySubCharacteristicId(Integer characteristicOrSubCharacteristicId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectBySubCharacteristicId(characteristicOrSubCharacteristicId, session);
} finally {
@@ -132,7 +132,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
@CheckForNull
public RuleDto selectById(Integer id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectById(id, session);
} finally {
@@ -148,7 +148,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
@CheckForNull
public RuleDto selectByKey(RuleKey ruleKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByKey(ruleKey, session);
} finally {
@@ -158,7 +158,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
@CheckForNull
public RuleDto selectByName(String name) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getMapper(session).selectByName(name);
} finally {
@@ -167,7 +167,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public void insert(Collection<RuleDto> rules) {
- SqlSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
for (RuleDto rule : rules) {
getMapper(session).batchInsert(rule);
@@ -183,7 +183,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
// ******************************
public List<RuleParamDto> selectParameters() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectParameters(session);
} finally {
@@ -196,7 +196,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public List<RuleParamDto> selectParametersByRuleId(Integer ruleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectParametersByRuleId(ruleId, session);
} finally {
@@ -209,7 +209,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public List<RuleParamDto> selectParametersByRuleIds(List<Integer> ruleIds) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectParametersByRuleIds(ruleIds, session);
} finally {
@@ -231,7 +231,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public void insert(RuleParamDto param) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insert(param, session);
session.commit();
@@ -245,7 +245,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public void update(RuleParamDto param) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
update(param, session);
session.commit();
@@ -288,7 +288,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public List<RuleRuleTagDto> selectTagsByRuleId(Integer ruleId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectTagsByRuleIds(ruleId, session);
} finally {
@@ -301,7 +301,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
}
public List<RuleRuleTagDto> selectTagsByRuleIds(List<Integer> ruleIds) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectTagsByRuleIds(ruleIds, session);
} finally {
@@ -320,7 +320,7 @@ public class RuleDao extends BaseDao<RuleDto, RuleKey>
@Override
public Collection<RuleKey> keysOfRowsUpdatedAfter(long timestamp) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
final List<RuleKey> keys = Lists.newArrayList();
session.select("selectKeysOfRulesUpdatedSince", new Timestamp(timestamp), new ResultHandler() {
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/RuleTagDao.java b/sonar-core/src/main/java/org/sonar/core/rule/RuleTagDao.java
index 5b1d243f402..ab227644610 100644
--- a/sonar-core/src/main/java/org/sonar/core/rule/RuleTagDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/rule/RuleTagDao.java
@@ -34,7 +34,7 @@ public class RuleTagDao implements ServerExtension {
}
public List<RuleTagDto> selectAll() {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectAll(session);
} finally {
@@ -47,7 +47,7 @@ public class RuleTagDao implements ServerExtension {
}
public void insert(RuleTagDto newRuleTag) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
insert(newRuleTag, session);
session.commit();
@@ -61,7 +61,7 @@ public class RuleTagDao implements ServerExtension {
}
public void delete(Long tagId) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
delete(tagId, session);
session.commit();
@@ -75,7 +75,7 @@ public class RuleTagDao implements ServerExtension {
}
public Long selectId(String tag) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectId(tag, session);
} finally {
@@ -88,7 +88,7 @@ public class RuleTagDao implements ServerExtension {
}
public List<RuleTagDto> selectUnused() {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return selectUnused(session);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java
index 48e9762a9ee..0b9ad5040d2 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotDataDao.java
@@ -40,7 +40,7 @@ public class SnapshotDataDao implements BatchComponent, ServerComponent {
}
public Collection<SnapshotDataDto> selectSnapshotData(long snapshotId, List<String> dataTypes) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
SnapshotDataMapper mapper = session.getMapper(SnapshotDataMapper.class);
return mapper.selectSnapshotData(snapshotId, dataTypes);
@@ -51,7 +51,7 @@ public class SnapshotDataDao implements BatchComponent, ServerComponent {
public Collection<SnapshotDataDto> selectSnapshotDataByComponentKey(String componentKey, List<String> dataTypes) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectSnapshotDataByComponentKey(componentKey, dataTypes, session);
} finally {
@@ -65,7 +65,7 @@ public class SnapshotDataDao implements BatchComponent, ServerComponent {
}
void insert(SnapshotDataDto snapshotData) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insert(session, snapshotData);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java
index d0e6742c882..e535f7a3340 100644
--- a/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/source/db/SnapshotSourceDao.java
@@ -39,7 +39,7 @@ public class SnapshotSourceDao implements ServerComponent {
@CheckForNull
public String selectSnapshotSource(long snapshotId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
SnapshotSourceMapper mapper = session.getMapper(SnapshotSourceMapper.class);
@@ -58,7 +58,7 @@ public class SnapshotSourceDao implements ServerComponent {
@CheckForNull
public String selectSnapshotSourceByComponentKey(String componentKey) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectSnapshotSourceByComponentKey(componentKey, session);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java
index b82c74f4c3a..1f6f8a5f6bd 100644
--- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/CharacteristicDao.java
@@ -45,7 +45,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
* @return enabled root characteristics and characteristics
*/
public List<CharacteristicDto> selectEnabledCharacteristics() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectEnabledCharacteristics(session);
} finally {
@@ -61,7 +61,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
* @return all characteristics
*/
public List<CharacteristicDto> selectCharacteristics() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectCharacteristics(session);
} finally {
@@ -77,7 +77,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
* @return only enabled root characteristics, order by order
*/
public List<CharacteristicDto> selectEnabledRootCharacteristics() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectEnabledRootCharacteristics(session);
} finally {
@@ -93,7 +93,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
}
public List<CharacteristicDto> selectCharacteristicsByParentId(int parentId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectCharacteristicsByParentId(parentId, session);
} finally {
@@ -106,7 +106,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
}
public List<CharacteristicDto> selectCharacteristicsByIds(Collection<Integer> ids) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectCharacteristicsByIds(ids, session);
} finally {
@@ -125,7 +125,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
@CheckForNull
public CharacteristicDto selectByKey(String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByKey(key, session);
} finally {
@@ -140,7 +140,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
@CheckForNull
public CharacteristicDto selectById(int id) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectById(id, session);
} finally {
@@ -155,7 +155,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
@CheckForNull
public CharacteristicDto selectByName(String name) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectByName(name, session);
} finally {
@@ -169,7 +169,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
}
public int selectMaxCharacteristicOrder() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectMaxCharacteristicOrder(session);
} finally {
@@ -187,7 +187,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
}
public void insert(CharacteristicDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insert(dto, session);
session.commit();
@@ -201,7 +201,7 @@ public class CharacteristicDao implements BatchComponent, ServerComponent {
}
public void update(CharacteristicDto dto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
update(dto, session);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java
index e57bf839505..89b3e2d746f 100644
--- a/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/technicaldebt/db/RequirementDao.java
@@ -34,7 +34,7 @@ public class RequirementDao implements ServerComponent {
}
public List<RequirementDto> selectRequirements() {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectRequirements(session);
} finally {
diff --git a/sonar-core/src/main/java/org/sonar/core/template/LoadedTemplateDao.java b/sonar-core/src/main/java/org/sonar/core/template/LoadedTemplateDao.java
index 0077ed68ff0..13eaee13017 100644
--- a/sonar-core/src/main/java/org/sonar/core/template/LoadedTemplateDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/template/LoadedTemplateDao.java
@@ -33,7 +33,7 @@ public class LoadedTemplateDao implements BatchComponent, ServerComponent {
}
public int countByTypeAndKey(String type, String key) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return countByTypeAndKey(type, key, session);
} finally {
@@ -47,7 +47,7 @@ public class LoadedTemplateDao implements BatchComponent, ServerComponent {
public void insert(LoadedTemplateDto loadedTemplateDto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insert(loadedTemplateDto, session);
session.commit();
diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java
index 698d67575c6..6f91c4e74fb 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorDao.java
@@ -42,7 +42,7 @@ public class AuthorDao implements BatchComponent, ServerComponent {
}
public AuthorDto selectByLogin(String login) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
return mapper.selectByLogin(login);
@@ -52,7 +52,7 @@ public class AuthorDao implements BatchComponent, ServerComponent {
}
public int countDeveloperLogins(long developerId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
AuthorMapper mapper = session.getMapper(AuthorMapper.class);
return mapper.countDeveloperLogins(developerId);
@@ -62,7 +62,7 @@ public class AuthorDao implements BatchComponent, ServerComponent {
}
public void insertAuthor(String login, long personId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insertAuthor(login, personId, session);
session.commit();
@@ -72,7 +72,7 @@ public class AuthorDao implements BatchComponent, ServerComponent {
}
public void insertAuthorAndDeveloper(String login, ResourceDto resourceDto) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
resourceDao.insertUsingExistingSession(resourceDto, session);
insertAuthor(login, resourceDto.getId(), session);
diff --git a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java
index ae9d648349a..faf3b1c89c0 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/AuthorizationDao.java
@@ -44,7 +44,7 @@ public class AuthorizationDao implements ServerComponent {
}
public Set<String> keepAuthorizedComponentKeys(Set<String> componentKeys, @Nullable Integer userId, String role) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return keepAuthorizedComponentKeys(componentKeys, userId, role, session);
@@ -75,7 +75,7 @@ public class AuthorizationDao implements ServerComponent {
}
public Collection<String> selectAuthorizedRootProjectsKeys(@Nullable Integer userId, String role) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectAuthorizedRootProjectsKeys(userId, role, session);
@@ -95,7 +95,7 @@ public class AuthorizationDao implements ServerComponent {
}
public List<String> selectGlobalPermissions(@Nullable String userLogin) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
Map<String, Object> params = newHashMap();
params.put("userLogin", userLogin);
diff --git a/sonar-core/src/main/java/org/sonar/core/user/GroupMembershipDao.java b/sonar-core/src/main/java/org/sonar/core/user/GroupMembershipDao.java
index ac5f4170ea1..6cc67f26e95 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/GroupMembershipDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/GroupMembershipDao.java
@@ -38,7 +38,7 @@ public class GroupMembershipDao {
}
public List<GroupMembershipDto> selectGroups(GroupMembershipQuery query, Long userId, int offset, int limit) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
Map<String, Object> params = ImmutableMap.of("query", query, "userId", userId);
return session.selectList("org.sonar.core.user.GroupMembershipMapper.selectGroups", params, new RowBounds(offset, limit));
diff --git a/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java b/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java
index cf6b23931ae..104f62402c5 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/RoleDao.java
@@ -38,7 +38,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public List<String> selectUserPermissions(String userLogin, @Nullable Long resourceId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
RoleMapper mapper = session.getMapper(RoleMapper.class);
try {
return mapper.selectUserPermissions(userLogin, resourceId);
@@ -48,7 +48,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public List<String> selectGroupPermissions(String groupName, @Nullable Long resourceId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
RoleMapper mapper = session.getMapper(RoleMapper.class);
try {
return mapper.selectGroupPermissions(groupName, resourceId, DefaultGroups.isAnyone(groupName));
@@ -58,7 +58,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public void insertGroupRole(GroupRoleDto groupRole) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insertGroupRole(groupRole, session);
session.commit();
@@ -73,7 +73,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public void insertUserRole(UserRoleDto userRole) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
insertUserRole(userRole, session);
session.commit();
@@ -88,7 +88,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public void deleteUserRole(UserRoleDto userRole) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteUserRole(userRole, session);
session.commit();
@@ -103,7 +103,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public void deleteGroupRole(GroupRoleDto groupRole) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
deleteGroupRole(groupRole, session);
session.commit();
@@ -128,7 +128,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public int countResourceGroupRoles(Long resourceId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
RoleMapper mapper = session.getMapper(RoleMapper.class);
return mapper.countResourceGroupRoles(resourceId);
@@ -138,7 +138,7 @@ public class RoleDao implements TaskComponent, ServerComponent {
}
public int countResourceUserRoles(Long resourceId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
RoleMapper mapper = session.getMapper(RoleMapper.class);
return mapper.countResourceUserRoles(resourceId);
diff --git a/sonar-core/src/main/java/org/sonar/core/user/UserDao.java b/sonar-core/src/main/java/org/sonar/core/user/UserDao.java
index 8baa7e1a298..9691f7d3b54 100644
--- a/sonar-core/src/main/java/org/sonar/core/user/UserDao.java
+++ b/sonar-core/src/main/java/org/sonar/core/user/UserDao.java
@@ -42,7 +42,7 @@ public class UserDao implements BatchComponent, ServerComponent {
}
public UserDto getUser(long userId) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return getUser(userId, session);
} finally {
@@ -61,7 +61,7 @@ public class UserDao implements BatchComponent, ServerComponent {
*/
@CheckForNull
public UserDto selectActiveUserByLogin(String login) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectActiveUserByLogin(login, session);
} finally {
@@ -77,7 +77,7 @@ public class UserDao implements BatchComponent, ServerComponent {
public List<UserDto> selectUsersByLogins(List<String> logins) {
List<UserDto> users = Lists.newArrayList();
if (!logins.isEmpty()) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
UserMapper mapper = session.getMapper(UserMapper.class);
List<List<String>> partitions = Lists.partition(logins, 1000);
@@ -92,7 +92,7 @@ public class UserDao implements BatchComponent, ServerComponent {
}
public List<UserDto> selectUsers(UserQuery query) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
UserMapper mapper = session.getMapper(UserMapper.class);
return mapper.selectUsers(query);
@@ -106,7 +106,7 @@ public class UserDao implements BatchComponent, ServerComponent {
* @return false if the user does not exist, true if the existing user has been deactivated
*/
public boolean deactivateUserByLogin(String login) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
UserMapper mapper = session.getMapper(UserMapper.class);
UserDto dto = mapper.selectUserByLogin(login);
@@ -145,7 +145,7 @@ public class UserDao implements BatchComponent, ServerComponent {
@CheckForNull
public GroupDto selectGroupByName(String name) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
return selectGroupByName(name, session);
} finally {
diff --git a/sonar-core/src/test/java/org/sonar/core/permission/PermissionTemplateDaoTest.java b/sonar-core/src/test/java/org/sonar/core/permission/PermissionTemplateDaoTest.java
index ce89cdfe07e..5a71651c35e 100644
--- a/sonar-core/src/test/java/org/sonar/core/permission/PermissionTemplateDaoTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/permission/PermissionTemplateDaoTest.java
@@ -20,13 +20,12 @@
package org.sonar.core.permission;
-import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Test;
import org.sonar.api.utils.System2;
import org.sonar.core.persistence.AbstractDaoTestCase;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -74,11 +73,11 @@ public class PermissionTemplateDaoTest extends AbstractDaoTestCase {
PermissionTemplateMapper mapper = mock(PermissionTemplateMapper.class);
- SonarSession session = mock(SonarSession.class);
+ DbSession session = mock(DbSession.class);
when(session.getMapper(PermissionTemplateMapper.class)).thenReturn(mapper);
MyBatis myBatis = mock(MyBatis.class);
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
permissionTemplateDao = new PermissionTemplateDao(myBatis, system);
PermissionTemplateDto permissionTemplate = permissionTemplateDao.createPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), null, null);
diff --git a/sonar-core/src/test/java/org/sonar/core/preview/PreviewCacheTest.java b/sonar-core/src/test/java/org/sonar/core/preview/PreviewCacheTest.java
index 08709cc35ee..834e319a060 100644
--- a/sonar-core/src/test/java/org/sonar/core/preview/PreviewCacheTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/preview/PreviewCacheTest.java
@@ -28,9 +28,9 @@ import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.sonar.api.platform.ServerFileSystem;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
import org.sonar.core.persistence.PreviewDatabaseFactory;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.properties.PropertiesDao;
import org.sonar.core.properties.PropertyDto;
import org.sonar.core.resource.ResourceDao;
@@ -57,7 +57,7 @@ public class PreviewCacheTest {
private MyBatis myBatis;
- private SonarSession session;
+ private DbSession session;
private PreviewCache dryRunCache;
private ServerFileSystem serverFileSystem;
@@ -71,8 +71,8 @@ public class PreviewCacheTest {
@Before
public void prepare() throws IOException {
myBatis = mock(MyBatis.class);
- session = mock(SonarSession.class);
- when(myBatis.openSession()).thenReturn(session);
+ session = mock(DbSession.class);
+ when(myBatis.openSession(false)).thenReturn(session);
serverFileSystem = mock(ServerFileSystem.class);
propertiesDao = mock(PropertiesDao.class);
resourceDao = mock(ResourceDao.class);
diff --git a/sonar-server/src/main/java/org/sonar/server/cluster/LocalNonBlockingWorkQueue.java b/sonar-server/src/main/java/org/sonar/server/cluster/LocalNonBlockingWorkQueue.java
index 3d54b9b7e7d..0a6b282f7ec 100644
--- a/sonar-server/src/main/java/org/sonar/server/cluster/LocalNonBlockingWorkQueue.java
+++ b/sonar-server/src/main/java/org/sonar/server/cluster/LocalNonBlockingWorkQueue.java
@@ -19,31 +19,29 @@
*/
package org.sonar.server.cluster;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.sonar.core.cluster.IndexAction;
import org.sonar.core.cluster.WorkQueue;
+import javax.annotation.CheckForNull;
import java.util.concurrent.ConcurrentLinkedQueue;
public class LocalNonBlockingWorkQueue implements WorkQueue {
- private static final Logger LOG = LoggerFactory.getLogger(LocalNonBlockingWorkQueue.class);
+ private final ConcurrentLinkedQueue<IndexAction<?>> actions = new ConcurrentLinkedQueue<IndexAction<?>>();
- private final ConcurrentLinkedQueue<IndexAction<?>> actions;
-
- public LocalNonBlockingWorkQueue() {
- this.actions = new ConcurrentLinkedQueue<IndexAction<?>>();
+ @Override
+ public void enqueue(IndexAction<?> indexAction) {
+ actions.offer(indexAction);
}
@Override
- public Integer enqueue(IndexAction<?>... indexActions) {
+ public void enqueue(Iterable<IndexAction<?>> indexActions) {
for (IndexAction<?> action : indexActions) {
- actions.offer(action);
+ enqueue(action);
}
- return 0;
}
+ @CheckForNull
@Override
public IndexAction<?> dequeue() {
IndexAction<?> out = actions.poll();
diff --git a/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrator.java b/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrator.java
index a5e3d44cd49..c67b21fb7c1 100644
--- a/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrator.java
+++ b/sonar-server/src/main/java/org/sonar/server/db/migrations/DatabaseMigrator.java
@@ -77,7 +77,7 @@ public class DatabaseMigrator implements ServerComponent, Startable {
SqlSession session = null;
Connection connection = null;
try {
- session = myBatis.openSession();
+ session = myBatis.openSession(false);
connection = session.getConnection();
createSchema(connection, database.getDialect().getId());
return true;
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
index 87620c2d1a3..2000feacf64 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelBackup.java
@@ -36,8 +36,8 @@ import org.sonar.api.server.rule.RulesDefinition;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.rule.RuleDao;
import org.sonar.core.rule.RuleDto;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
@@ -112,7 +112,7 @@ public class DebtModelBackup implements ServerComponent {
private String backupFromLanguage(@Nullable String languageKey) {
checkPermission();
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
DebtModel debtModel = new DebtModel();
List<CharacteristicDto> characteristicDtos = dao.selectEnabledCharacteristics(session);
@@ -147,7 +147,7 @@ public class DebtModelBackup implements ServerComponent {
checkPermission();
Date updateDate = new Date(system2.now());
- SonarSession session = mybatis.openSession();
+ DbSession session = mybatis.openSession(false);
try {
// Restore characteristics
List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(loadModelFromPlugin(DebtModelPluginRepository.DEFAULT_MODEL), updateDate, session);
@@ -172,7 +172,7 @@ public class DebtModelBackup implements ServerComponent {
}
}
- private void resetRules(List<RuleDto> ruleDtos, List<RulesDefinition.Rule> rules, List<CharacteristicDto> allCharacteristicDtos, Date updateDate, SonarSession session){
+ private void resetRules(List<RuleDto> ruleDtos, List<RulesDefinition.Rule> rules, List<CharacteristicDto> allCharacteristicDtos, Date updateDate, DbSession session){
for (RuleDto rule : ruleDtos) {
// Restore default debt definitions
@@ -226,7 +226,7 @@ public class DebtModelBackup implements ServerComponent {
ValidationMessages validationMessages = ValidationMessages.create();
Date updateDate = new Date(system2.now());
- SonarSession session = mybatis.openSession();
+ DbSession session = mybatis.openSession(false);
try {
List<CharacteristicDto> allCharacteristicDtos = restoreCharacteristics(characteristicsXMLImporter.importXML(xml), updateDate, session);
restoreRules(allCharacteristicDtos, rules(languageKey, session), rulesXMLImporter.importXML(xml, validationMessages), validationMessages, updateDate, session);
@@ -242,7 +242,7 @@ public class DebtModelBackup implements ServerComponent {
}
private void restoreRules(List<CharacteristicDto> allCharacteristicDtos, List<RuleDto> rules, List<RuleDebt> ruleDebts,
- ValidationMessages validationMessages, Date updateDate, SonarSession session) {
+ ValidationMessages validationMessages, Date updateDate, DbSession session) {
for (RuleDto rule : rules) {
RuleDebt ruleDebt = ruleDebt(rule.getRepositoryKey(), rule.getRuleKey(), ruleDebts);
String subCharacteristicKey = ruleDebt != null ? ruleDebt.subCharacteristicKey() : null;
@@ -262,7 +262,7 @@ public class DebtModelBackup implements ServerComponent {
}
@VisibleForTesting
- List<CharacteristicDto> restoreCharacteristics(DebtModel targetModel, Date updateDate, SonarSession session) {
+ List<CharacteristicDto> restoreCharacteristics(DebtModel targetModel, Date updateDate, DbSession session) {
List<CharacteristicDto> sourceCharacteristics = dao.selectEnabledCharacteristics(session);
List<CharacteristicDto> result = newArrayList();
diff --git a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
index 1be25ce39a4..cc4a6eace9e 100644
--- a/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
+++ b/sonar-server/src/main/java/org/sonar/server/debt/DebtModelOperations.java
@@ -29,8 +29,8 @@ import org.sonar.api.server.debt.DebtCharacteristic;
import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.utils.System2;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.rule.RuleDao;
import org.sonar.core.rule.RuleDto;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
@@ -71,7 +71,7 @@ public class DebtModelOperations implements ServerComponent {
public DebtCharacteristic create(String name, @Nullable Integer parentId) {
checkPermission();
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
checkNotAlreadyExists(name, session);
@@ -103,7 +103,7 @@ public class DebtModelOperations implements ServerComponent {
public DebtCharacteristic rename(int characteristicId, String newName) {
checkPermission();
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
checkNotAlreadyExists(newName, session);
@@ -131,7 +131,7 @@ public class DebtModelOperations implements ServerComponent {
private DebtCharacteristic move(int characteristicId, boolean moveUpOrDown) {
checkPermission();
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
final CharacteristicDto dto = findCharacteristic(characteristicId, session);
if (dto.getParentId() != null) {
@@ -191,7 +191,7 @@ public class DebtModelOperations implements ServerComponent {
checkPermission();
Date updateDate = new Date(system2.now());
- SonarSession session = mybatis.openBatchSession();
+ DbSession session = mybatis.openSession(true);
try {
delete(findCharacteristic(characteristicId, session), updateDate, session);
session.commit();
@@ -204,7 +204,7 @@ public class DebtModelOperations implements ServerComponent {
* Disabled a characteristic or a sub characteristic.
* If it has already been disabled, do nothing (for instance when call on a list of characteristics and sub-characteristics in random order)
*/
- public void delete(CharacteristicDto characteristicOrSubCharacteristic, Date updateDate, SonarSession session) {
+ public void delete(CharacteristicDto characteristicOrSubCharacteristic, Date updateDate, DbSession session) {
// Do nothing is the characteristic is already disabled
if (characteristicOrSubCharacteristic.isEnabled()) {
// When root characteristic, browse sub characteristics and disable rule debt on each sub characteristic then disable it
@@ -221,7 +221,7 @@ public class DebtModelOperations implements ServerComponent {
}
}
- private void disableSubCharacteristic(CharacteristicDto subCharacteristic, Date updateDate, SonarSession session) {
+ private void disableSubCharacteristic(CharacteristicDto subCharacteristic, Date updateDate, DbSession session) {
// Disable debt on all rules (even REMOVED ones, in order to have no issue if they are reactivated) linked to the sub characteristic
disableRulesDebt(ruleDao.selectBySubCharacteristicId(subCharacteristic.getId(), session), subCharacteristic.getId(), updateDate, session);
disableCharacteristic(subCharacteristic, updateDate, session);
@@ -233,7 +233,7 @@ public class DebtModelOperations implements ServerComponent {
dao.update(characteristic, session);
}
- private void disableRulesDebt(List<RuleDto> ruleDtos, Integer subCharacteristicId, Date updateDate, SonarSession session) {
+ private void disableRulesDebt(List<RuleDto> ruleDtos, Integer subCharacteristicId, Date updateDate, DbSession session) {
for (RuleDto ruleDto : ruleDtos) {
if (subCharacteristicId.equals(ruleDto.getSubCharacteristicId())) {
ruleDto.setSubCharacteristicId(RuleDto.DISABLED_CHARACTERISTIC_ID);
diff --git a/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java b/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java
index bf42960f640..4e8d3f6d78f 100644
--- a/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java
+++ b/sonar-server/src/main/java/org/sonar/server/issue/DefaultIssueFinder.java
@@ -97,7 +97,7 @@ public class DefaultIssueFinder implements IssueFinder {
public IssueQueryResult find(IssueQuery query) {
LOG.debug("IssueQuery : {}", query);
long start = System.currentTimeMillis();
- SqlSession sqlSession = myBatis.openSession();
+ SqlSession sqlSession = myBatis.openSession(false);
try {
// 1. Select the authorized ids of all the issues that match the query
List<IssueDto> authorizedIssues = issueDao.selectIssueIds(query, UserSession.get().userId(), sqlSession);
diff --git a/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java b/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
index f8d8c64556f..09978473782 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualitygate/QualityGates.java
@@ -115,7 +115,7 @@ public class QualityGates {
getNonNullQgate(sourceId);
validateQualityGate(null, destinationName);
QualityGateDto destinationGate = new QualityGateDto().setName(destinationName);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
dao.insert(destinationGate, session);
for (QualityGateConditionDto sourceCondition : conditionDao.selectForQualityGate(sourceId, session)) {
@@ -140,7 +140,7 @@ public class QualityGates {
public void delete(long idToDelete) {
checkPermission(UserSession.get());
QualityGateDto qGate = getNonNullQgate(idToDelete);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
if (isDefault(qGate)) {
propertiesDao.deleteGlobalProperty(SONAR_QUALITYGATE_PROPERTY, session);
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ESActiveRule.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ESActiveRule.java
index 5f097f8aed6..053facc9c25 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/ESActiveRule.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/ESActiveRule.java
@@ -68,7 +68,7 @@ public class ESActiveRule {
}
public void bulkRegisterActiveRules() {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
StopWatch bulkWatch = startWatch();
@@ -89,7 +89,7 @@ public class ESActiveRule {
}
public void bulkIndexProfile(int profileId) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
bulkIndexProfile(profileId, session);
} finally {
@@ -106,7 +106,7 @@ public class ESActiveRule {
}
public void bulkIndexActiveRules(List<Integer> ids) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
bulkIndexActiveRuleIds(ids, session);
} finally {
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperations.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperations.java
index f5d9beb7adc..789e01b5f70 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperations.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperations.java
@@ -86,7 +86,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
validatePermission(userSession);
validateSeverity(severity);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto profile = findProfileNotNull(profileId, session);
RuleDto rule = findRuleNotNull(ruleId, session);
@@ -147,7 +147,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
public int activateRules(int profileId, ProfileRuleQuery query, UserSession userSession) {
validatePermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
List<Integer> ruleIdsToActivate = rules.searchInactiveProfileRuleIds(query);
for (Integer ruleId : ruleIdsToActivate) {
@@ -162,7 +162,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
public boolean deactivateRule(int profileId, int ruleId, UserSession userSession) {
validatePermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ActiveRuleDto activeRule = findActiveRuleNotNull(profileId, ruleId, session);
return deactivateRule(activeRule, userSession, session);
@@ -189,7 +189,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
public int deactivateRules(ProfileRuleQuery query, UserSession userSession) {
validatePermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
int numberOfDeactivatedRules = 0;
try {
List<Integer> activeRuleIdsToDeactivate = rules.searchProfileRuleIds(query);
@@ -208,7 +208,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
public void updateActiveRuleParam(int activeRuleId, String key, @Nullable String value, UserSession userSession) {
validatePermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
String sanitizedValue = Strings.emptyToNull(value);
ActiveRuleParamDto activeRuleParam = findActiveRuleParam(activeRuleId, key, session);
@@ -272,7 +272,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
public void revertActiveRule(int activeRuleId, UserSession userSession) {
validatePermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ActiveRuleDto activeRule = findActiveRuleNotNull(activeRuleId, session);
if (activeRule.doesOverride()) {
@@ -368,7 +368,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
public void updateActiveRuleNote(int activeRuleId, String note, UserSession userSession) {
validatePermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ActiveRuleDto activeRule = findActiveRuleNotNull(activeRuleId, session);
@@ -394,7 +394,7 @@ public class QProfileActiveRuleOperations implements ServerComponent {
public void deleteActiveRuleNote(int activeRuleId, UserSession userSession) {
validatePermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ActiveRuleDto activeRule = findActiveRuleNotNull(activeRuleId, session);
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackup.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackup.java
index f3627c9de81..a94ffe26729 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackup.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackup.java
@@ -101,7 +101,7 @@ public class QProfileBackup implements ServerComponent {
public QProfileResult restore(String xmlBackup, boolean deleteExisting) {
checkPermission(UserSession.get());
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
QProfileResult result = new QProfileResult();
try {
ValidationMessages messages = ValidationMessages.create();
@@ -136,7 +136,7 @@ public class QProfileBackup implements ServerComponent {
checkPermission(UserSession.get());
QProfileResult result = new QProfileResult();
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ListMultimap<String, RulesProfile> profilesByName = profilesByName(language, result);
for (Map.Entry<String, Collection<RulesProfile>> entry : profilesByName.asMap().entrySet()) {
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
index 1b38d2a35ec..b6c15ae3df6 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileLookup.java
@@ -54,7 +54,7 @@ public class QProfileLookup implements ServerComponent {
@CheckForNull
public QProfile profile(int id) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return profile(id, session);
} finally {
@@ -81,7 +81,7 @@ public class QProfileLookup implements ServerComponent {
@CheckForNull
public QProfile profile(String name, String language) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return profile(name, language, session);
} finally {
@@ -91,7 +91,7 @@ public class QProfileLookup implements ServerComponent {
@CheckForNull
public QProfile defaultProfile(String language) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return defaultProfile(language, session);
} finally {
@@ -110,7 +110,7 @@ public class QProfileLookup implements ServerComponent {
@CheckForNull
public QProfile parent(QProfile profile) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
String parent = profile.parent();
if (parent != null) {
@@ -126,7 +126,7 @@ public class QProfileLookup implements ServerComponent {
}
public List<QProfile> children(QProfile profile) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return children(profile, session);
} finally {
@@ -140,7 +140,7 @@ public class QProfileLookup implements ServerComponent {
public List<QProfile> ancestors(QProfile profile) {
List<QProfile> ancestors = newArrayList();
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
incrementAncestors(profile, ancestors, session);
} finally {
@@ -158,7 +158,7 @@ public class QProfileLookup implements ServerComponent {
}
public boolean isDeletable(QProfile profile) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return isDeletable(profile, session);
} finally {
@@ -179,7 +179,7 @@ public class QProfileLookup implements ServerComponent {
}
public int countChildren(QProfile profile) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
return countChildren(profile, session);
} finally {
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java
index d5ae6749c09..8a826a10fb0 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileOperations.java
@@ -69,7 +69,7 @@ public class QProfileOperations implements ServerComponent {
}
public QProfileResult newProfile(String name, String language, Map<String, String> xmlProfilesByPlugin, UserSession userSession) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QProfile profile = newProfile(name, language, true, userSession, session);
@@ -103,7 +103,7 @@ public class QProfileOperations implements ServerComponent {
public void renameProfile(int profileId, String newName, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto profileDto = findNotNull(profileId, session);
String oldName = profileDto.getName();
@@ -129,7 +129,7 @@ public class QProfileOperations implements ServerComponent {
public void deleteProfile(int profileId, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto profile = findNotNull(profileId, session);
QProfile qProfile = QProfile.from(profile);
@@ -158,7 +158,7 @@ public class QProfileOperations implements ServerComponent {
public void setDefaultProfile(int profileId, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto qualityProfile = findNotNull(profileId, session);
propertiesDao.setProperty(new PropertyDto().setKey(PROFILE_PROPERTY_PREFIX + qualityProfile.getLanguage()).setValue(qualityProfile.getName()));
@@ -170,7 +170,7 @@ public class QProfileOperations implements ServerComponent {
public void updateParentProfile(int profileId, @Nullable Integer parentId, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto profile = findNotNull(profileId, session);
QualityProfileDto parentProfile = null;
@@ -196,7 +196,7 @@ public class QProfileOperations implements ServerComponent {
public void copyProfile(int profileId, String copyProfileName, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto profileDto = findNotNull(profileId, session);
checkNotAlreadyExists(copyProfileName, profileDto.getLanguage(), session);
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java
index a2b6221762b..dab7aa21172 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectLookup.java
@@ -44,7 +44,7 @@ public class QProfileProjectLookup implements ServerComponent {
}
public List<Component> projects(int profileId) {
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto qualityProfile = qualityProfileDao.selectById(profileId, session);
QProfileValidations.checkProfileIsNotNull(qualityProfile);
diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java
index bd84a0c15e3..7ae201b6ded 100644
--- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java
+++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileProjectOperations.java
@@ -50,7 +50,7 @@ public class QProfileProjectOperations implements ServerComponent {
public void addProject(int profileId, long projectId, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ComponentDto project = (ComponentDto) findProjectNotNull(projectId, session);
QualityProfileDto qualityProfile = findNotNull(profileId, session);
@@ -65,7 +65,7 @@ public class QProfileProjectOperations implements ServerComponent {
public void removeProject(int profileId, long projectId, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ComponentDto project = (ComponentDto) findProjectNotNull(projectId, session);
QualityProfileDto qualityProfile = findNotNull(profileId, session);
@@ -79,7 +79,7 @@ public class QProfileProjectOperations implements ServerComponent {
public void removeProject(String language, long projectId, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ComponentDto project = (ComponentDto) findProjectNotNull(projectId, session);
@@ -92,7 +92,7 @@ public class QProfileProjectOperations implements ServerComponent {
public void removeAllProjects(int profileId, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
QualityProfileDto qualityProfile = findNotNull(profileId, session);
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java b/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
index ff91d9bd72d..6cf13c12131 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java
@@ -42,8 +42,8 @@ import org.sonar.api.utils.MessageException;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.TimeProfiler;
import org.sonar.check.Cardinality;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.qualityprofile.db.ActiveRuleDao;
import org.sonar.core.rule.RuleDao;
import org.sonar.core.rule.RuleDto;
@@ -119,7 +119,7 @@ public class RegisterRules implements Startable {
@Override
public void start() {
TimeProfiler profiler = new TimeProfiler().start("Register rules");
- SonarSession sqlSession = myBatis.openSession();
+ DbSession sqlSession = myBatis.openSession(false);
try {
RulesDefinition.Context context = defLoader.load();
Buffer buffer = new Buffer(system.now());
@@ -161,7 +161,7 @@ public class RegisterRules implements Startable {
}
}
- private void enableRuleDefinitions(RulesDefinition.Context context, Buffer buffer, SonarSession sqlSession) {
+ private void enableRuleDefinitions(RulesDefinition.Context context, Buffer buffer, DbSession sqlSession) {
for (RulesDefinition.Repository repoDef : context.repositories()) {
enableRepository(buffer, sqlSession, repoDef);
}
@@ -174,7 +174,7 @@ public class RegisterRules implements Startable {
}
}
- private void enableRepository(Buffer buffer, SonarSession sqlSession, RulesDefinition.ExtendedRepository repoDef) {
+ private void enableRepository(Buffer buffer, DbSession sqlSession, RulesDefinition.ExtendedRepository repoDef) {
int count = 0;
for (RulesDefinition.Rule ruleDef : repoDef.rules()) {
RuleDto dto = buffer.rule(RuleKey.of(ruleDef.repository().key(), ruleDef.key()));
@@ -192,7 +192,7 @@ public class RegisterRules implements Startable {
sqlSession.commit();
}
- private RuleDto enableAndInsert(Buffer buffer, SonarSession sqlSession, RulesDefinition.Rule ruleDef) {
+ private RuleDto enableAndInsert(Buffer buffer, DbSession sqlSession, RulesDefinition.Rule ruleDef) {
RuleDto ruleDto = new RuleDto()
.setCardinality(ruleDef.template() ? Cardinality.MULTIPLE : Cardinality.SINGLE)
.setConfigKey(ruleDef.internalKey())
@@ -233,7 +233,7 @@ public class RegisterRules implements Startable {
return ruleDto;
}
- private void enableAndUpdate(Buffer buffer, SonarSession sqlSession, RulesDefinition.Rule ruleDef, RuleDto dto) {
+ private void enableAndUpdate(Buffer buffer, DbSession sqlSession, RulesDefinition.Rule ruleDef, RuleDto dto) {
if (mergeRule(buffer, ruleDef, dto)) {
ruleDao.update(dto, sqlSession);
}
@@ -426,7 +426,7 @@ public class RegisterRules implements Startable {
return tagId;
}
- private List<RuleDto> processRemainingDbRules(Buffer buffer, SonarSession sqlSession) {
+ private List<RuleDto> processRemainingDbRules(Buffer buffer, DbSession sqlSession) {
List<RuleDto> removedRules = newArrayList();
for (Integer unprocessedRuleId : buffer.unprocessedRuleIds) {
RuleDto ruleDto = buffer.rulesById.get(unprocessedRuleId);
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java b/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
index 3a554e0bff9..53596b210de 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RuleOperations.java
@@ -37,8 +37,8 @@ import org.sonar.api.server.debt.internal.DefaultDebtRemediationFunction;
import org.sonar.api.utils.System2;
import org.sonar.check.Cardinality;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.qualityprofile.db.ActiveRuleDao;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.rule.RuleDao;
@@ -100,7 +100,7 @@ public class RuleOperations implements ServerComponent {
checkPermission(userSession);
Date now = new Date(system.now());
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
if (rule.getNoteData() == null) {
rule.setNoteCreatedAt(now);
@@ -120,7 +120,7 @@ public class RuleOperations implements ServerComponent {
public void deleteRuleNote(RuleDto rule, UserSession userSession) {
checkPermission(userSession);
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
rule.setNoteData(null);
rule.setNoteUserLogin(null);
@@ -138,7 +138,7 @@ public class RuleOperations implements ServerComponent {
public RuleDto createCustomRule(RuleDto templateRule, String name, String severity, String description, Map<String, String> paramsByKey,
UserSession userSession) {
checkPermission(userSession);
- SonarSession session = myBatis.openSession();
+ DbSession session = myBatis.openSession(false);
try {
RuleDto rule = new RuleDto()
.setParentId(templateRule.getId())
@@ -194,7 +194,7 @@ public class RuleOperations implements ServerComponent {
public void updateCustomRule(RuleDto rule, String name, String severity, String description, Map<String, String> paramsByKey,
UserSession userSession) {
checkPermission(userSession);
- SonarSession session = myBatis.openSession();
+ DbSession session = myBatis.openSession(false);
try {
rule.setName(name)
.setDescription(description)
@@ -217,7 +217,7 @@ public class RuleOperations implements ServerComponent {
public void deleteCustomRule(RuleDto rule, UserSession userSession) {
checkPermission(userSession);
- SonarSession session = myBatis.openSession();
+ DbSession session = myBatis.openSession(false);
try {
// Set status REMOVED on rule
rule.setStatus(Rule.STATUS_REMOVED)
@@ -246,7 +246,7 @@ public class RuleOperations implements ServerComponent {
public void updateRuleTags(RuleDto rule, List<String> newTags, UserSession userSession) {
checkPermission(userSession);
- SonarSession session = myBatis.openSession();
+ DbSession session = myBatis.openSession(false);
try {
Map<String, Long> neededTagIds = validateAndGetTagIds(newTags, session);
@@ -266,7 +266,7 @@ public class RuleOperations implements ServerComponent {
public void updateRule(RuleChange ruleChange, UserSession userSession) {
checkPermission(userSession);
- SonarSession session = myBatis.openSession();
+ DbSession session = myBatis.openSession(false);
try {
RuleDto ruleDto = ruleDao.selectByKey(ruleChange.ruleKey(), session);
if (ruleDto == null) {
@@ -297,7 +297,7 @@ public class RuleOperations implements ServerComponent {
}
public boolean updateRule(RuleDto ruleDto, @Nullable CharacteristicDto newSubCharacteristic, @Nullable String newFunction,
- @Nullable String newCoefficient, @Nullable String newOffset, Date updateDate, SonarSession session) {
+ @Nullable String newCoefficient, @Nullable String newOffset, Date updateDate, DbSession session) {
boolean needUpdate = false;
// A sub-characteristic and a remediation function is given -> update rule debt
diff --git a/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java b/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java
index 07215e3c0d2..99f7c9aa789 100644
--- a/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java
+++ b/sonar-server/src/main/java/org/sonar/server/rule/RuleRegistry.java
@@ -106,7 +106,7 @@ public class RuleRegistry {
* Reindex all enabled and non manual rules
*/
public String[] reindex() {
- SqlSession sqlSession = myBatis.openSession();
+ SqlSession sqlSession = myBatis.openSession(false);
try {
return reindex(sqlSession);
} finally {
@@ -161,7 +161,7 @@ public class RuleRegistry {
* Reindex one rule
*/
public void reindex(RuleDto rule) {
- SqlSession sqlSession = myBatis.openSession();
+ SqlSession sqlSession = myBatis.openSession(false);
try {
reindex(rule, sqlSession);
} finally {
diff --git a/sonar-server/src/main/java/org/sonar/server/source/DeprecatedSourceDecorator.java b/sonar-server/src/main/java/org/sonar/server/source/DeprecatedSourceDecorator.java
index 57f82f496b3..907225ab4d1 100644
--- a/sonar-server/src/main/java/org/sonar/server/source/DeprecatedSourceDecorator.java
+++ b/sonar-server/src/main/java/org/sonar/server/source/DeprecatedSourceDecorator.java
@@ -62,7 +62,7 @@ public class DeprecatedSourceDecorator implements ServerComponent {
@CheckForNull
public List<String> getSourceAsHtml(String componentKey, @Nullable Integer from, @Nullable Integer to) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
ResourceDto component = resourceDao.getResource(ResourceQuery.create().setKey(componentKey), session);
if (component == null) {
diff --git a/sonar-server/src/main/java/org/sonar/server/source/HtmlSourceDecorator.java b/sonar-server/src/main/java/org/sonar/server/source/HtmlSourceDecorator.java
index 65c8831f826..8df8c2e59bd 100644
--- a/sonar-server/src/main/java/org/sonar/server/source/HtmlSourceDecorator.java
+++ b/sonar-server/src/main/java/org/sonar/server/source/HtmlSourceDecorator.java
@@ -50,7 +50,7 @@ public class HtmlSourceDecorator implements ServerComponent {
}
public List<String> getDecoratedSourceAsHtml(String componentKey, @Nullable Integer from, @Nullable Integer to) {
- SqlSession session = mybatis.openSession();
+ SqlSession session = mybatis.openSession(false);
try {
Collection<SnapshotDataDto> snapshotDataEntries = snapshotDataDao.selectSnapshotDataByComponentKey(componentKey, highlightingDataTypes(), session);
if (!snapshotDataEntries.isEmpty()) {
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityProfiles.java b/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityProfiles.java
index b9518b4bd5d..94fe7d579b7 100644
--- a/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityProfiles.java
+++ b/sonar-server/src/main/java/org/sonar/server/startup/RegisterQualityProfiles.java
@@ -102,7 +102,7 @@ public class RegisterQualityProfiles {
// As long ProfileDefinition API will be used, then we'll have to use this commit as Hibernate is used by plugin to load rules when creating their profiles.
sessionFactory.getSession().commit();
- SqlSession session = myBatis.openSession();
+ SqlSession session = myBatis.openSession(false);
try {
ListMultimap<String, RulesProfile> profilesByLanguage = profilesByLanguage();
for (String language : profilesByLanguage.keySet()) {
diff --git a/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigratorTest.java b/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigratorTest.java
index b5729aaaaf8..5add093adfb 100644
--- a/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigratorTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/db/migrations/DatabaseMigratorTest.java
@@ -26,8 +26,8 @@ import org.junit.rules.ExpectedException;
import org.sonar.api.platform.ServerUpgradeStatus;
import org.sonar.core.persistence.AbstractDaoTestCase;
import org.sonar.core.persistence.Database;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.persistence.dialect.Dialect;
import org.sonar.core.persistence.dialect.H2;
import org.sonar.core.persistence.dialect.MySql;
@@ -84,9 +84,9 @@ public class DatabaseMigratorTest extends AbstractDaoTestCase {
Dialect supportedDialect = new H2();
when(database.getDialect()).thenReturn(supportedDialect);
Connection connection = mock(Connection.class);
- SonarSession session = mock(SonarSession.class);
+ DbSession session = mock(DbSession.class);
when(session.getConnection()).thenReturn(connection);
- when(mybatis.openSession()).thenReturn(session);
+ when(mybatis.openSession(false)).thenReturn(session);
when(serverUpgradeStatus.isFreshInstall()).thenReturn(true);
DatabaseMigrator databaseMigrator = new DatabaseMigrator(mybatis, database, migrations, serverUpgradeStatus, null) {
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
index 455aef1db1b..6481af00e21 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelBackupTest.java
@@ -20,7 +20,6 @@
package org.sonar.server.debt;
-import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -40,8 +39,8 @@ import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.rule.RuleDao;
import org.sonar.core.rule.RuleDto;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
@@ -81,7 +80,7 @@ public class DebtModelBackupTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
DebtModelPluginRepository debtModelPluginRepository;
@@ -147,9 +146,9 @@ public class DebtModelBackupTest {
dto.setId(currentId++);
return null;
}
- }).when(dao).insert(any(CharacteristicDto.class), any(SonarSession.class));
+ }).when(dao).insert(any(CharacteristicDto.class), any(DbSession.class));
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
Reader defaultModelReader = mock(Reader.class);
when(debtModelPluginRepository.createReaderForXMLFile("technical-debt")).thenReturn(defaultModelReader);
diff --git a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
index 8d96e8b4937..df890a22bbb 100644
--- a/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/debt/DebtModelOperationsTest.java
@@ -35,9 +35,8 @@ import org.sonar.api.server.debt.internal.DefaultDebtCharacteristic;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.core.persistence.BatchSession;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.rule.RuleDao;
import org.sonar.core.rule.RuleDto;
import org.sonar.core.technicaldebt.db.CharacteristicDao;
@@ -75,7 +74,7 @@ public class DebtModelOperationsTest {
MyBatis mybatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
RuleRegistry ruleRegistry;
@@ -126,7 +125,7 @@ public class DebtModelOperationsTest {
}
}).when(dao).insert(any(CharacteristicDto.class), any(SqlSession.class));
- when(mybatis.openSession()).thenReturn(session);
+ when(mybatis.openSession(false)).thenReturn(session);
service = new DebtModelOperations(mybatis, dao, ruleDao, ruleRegistry, system2);
}
@@ -353,8 +352,8 @@ public class DebtModelOperationsTest {
@Test
public void delete_sub_characteristic() {
- BatchSession batchSession = mock(BatchSession.class);
- when(mybatis.openBatchSession()).thenReturn(batchSession);
+ DbSession batchSession = mock(DbSession.class);
+ when(mybatis.openSession(true)).thenReturn(batchSession);
when(ruleDao.selectBySubCharacteristicId(2, batchSession)).thenReturn(newArrayList(
new RuleDto()
@@ -395,8 +394,8 @@ public class DebtModelOperationsTest {
@Test
public void delete_sub_characteristic_disable_default_rules_debt_if_default_characteristic_is_deleted() {
- BatchSession batchSession = mock(BatchSession.class);
- when(mybatis.openBatchSession()).thenReturn(batchSession);
+ DbSession batchSession = mock(DbSession.class);
+ when(mybatis.openSession(true)).thenReturn(batchSession);
when(ruleDao.selectBySubCharacteristicId(2, batchSession)).thenReturn(newArrayList(
new RuleDto()
@@ -436,8 +435,8 @@ public class DebtModelOperationsTest {
@Test
public void delete_characteristic() {
- BatchSession batchSession = mock(BatchSession.class);
- when(mybatis.openBatchSession()).thenReturn(batchSession);
+ DbSession batchSession = mock(DbSession.class);
+ when(mybatis.openSession(true)).thenReturn(batchSession);
when(ruleDao.selectBySubCharacteristicId(subCharacteristicDto.getId(), batchSession)).thenReturn(newArrayList(
new RuleDto().setSubCharacteristicId(subCharacteristicDto.getId()).setRemediationFunction("LINEAR_OFFSET").setRemediationCoefficient("2h").setRemediationOffset("5min")
@@ -470,8 +469,8 @@ public class DebtModelOperationsTest {
@Test
public void not_delete_already_disabled_characteristic() {
- BatchSession batchSession = mock(BatchSession.class);
- when(mybatis.openBatchSession()).thenReturn(batchSession);
+ DbSession batchSession = mock(DbSession.class);
+ when(mybatis.openSession(true)).thenReturn(batchSession);
when(dao.selectById(1, batchSession)).thenReturn(new CharacteristicDto()
.setId(1)
diff --git a/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java b/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
index 40c235dd145..6719b9895a4 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualitygate/QualityGatesTest.java
@@ -21,7 +21,6 @@ package org.sonar.server.qualitygate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
-import org.apache.ibatis.session.SqlSession;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -39,8 +38,8 @@ import org.sonar.core.component.ComponentDto;
import org.sonar.core.component.ComponentQuery;
import org.sonar.core.component.db.ComponentDao;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.properties.PropertiesDao;
import org.sonar.core.properties.PropertyDto;
import org.sonar.core.qualitygate.db.QualityGateConditionDao;
@@ -235,8 +234,8 @@ public class QualityGatesTest {
String name = "To Delete";
QualityGateDto toDelete = new QualityGateDto().setId(idToDelete).setName(name);
when(dao.selectById(idToDelete)).thenReturn(toDelete);
- SonarSession session = mock(SonarSession.class);
- when(myBatis.openSession()).thenReturn(session);
+ DbSession session = mock(DbSession.class);
+ when(myBatis.openSession(false)).thenReturn(session);
qGates.delete(idToDelete);
verify(dao).selectById(idToDelete);
verify(propertiesDao).deleteProjectProperties("sonar.qualitygate", "42", session);
@@ -250,8 +249,8 @@ public class QualityGatesTest {
QualityGateDto toDelete = new QualityGateDto().setId(idToDelete).setName(name);
when(dao.selectById(idToDelete)).thenReturn(toDelete);
when(propertiesDao.selectGlobalProperty("sonar.qualitygate")).thenReturn(new PropertyDto().setValue("666"));
- SonarSession session = mock(SonarSession.class);
- when(myBatis.openSession()).thenReturn(session);
+ DbSession session = mock(DbSession.class);
+ when(myBatis.openSession(false)).thenReturn(session);
qGates.delete(idToDelete);
verify(dao).selectById(idToDelete);
verify(propertiesDao).deleteProjectProperties("sonar.qualitygate", "42", session);
@@ -265,8 +264,8 @@ public class QualityGatesTest {
QualityGateDto toDelete = new QualityGateDto().setId(idToDelete).setName(name);
when(dao.selectById(idToDelete)).thenReturn(toDelete);
when(propertiesDao.selectGlobalProperty("sonar.qualitygate")).thenReturn(new PropertyDto().setValue("42"));
- SonarSession session = mock(SonarSession.class);
- when(myBatis.openSession()).thenReturn(session);
+ DbSession session = mock(DbSession.class);
+ when(myBatis.openSession(false)).thenReturn(session);
qGates.delete(idToDelete);
verify(dao).selectById(idToDelete);
verify(propertiesDao).deleteGlobalProperty("sonar.qualitygate", session);
@@ -537,8 +536,8 @@ public class QualityGatesTest {
Collection<QualityGateConditionDto> conditions = ImmutableList.of(cond1, cond2);
when(dao.selectById(sourceId)).thenReturn(new QualityGateDto().setId(sourceId).setName("SG-1"));
- SonarSession session = mock(SonarSession.class);
- when(myBatis.openSession()).thenReturn(session);
+ DbSession session = mock(DbSession.class);
+ when(myBatis.openSession(false)).thenReturn(session);
Mockito.doAnswer(new Answer<Object>() {
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ESActiveRuleTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ESActiveRuleTest.java
index 24e487ae4e7..490844a11b4 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/ESActiveRuleTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/ESActiveRuleTest.java
@@ -26,7 +26,6 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.common.io.Resources;
-import org.apache.ibatis.session.SqlSession;
import org.elasticsearch.client.Requests;
import org.elasticsearch.common.settings.ImmutableSettings;
import org.elasticsearch.search.SearchHit;
@@ -38,8 +37,8 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.api.config.Settings;
import org.sonar.api.rule.Severity;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.profiling.Profiling;
import org.sonar.core.qualityprofile.db.ActiveRuleDao;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
@@ -74,14 +73,14 @@ public class ESActiveRuleTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
ActiveRuleDao activeRuleDao;
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(ESNode.class.getResource("config/elasticsearch.json")).build());
esSetup.execute(EsSetup.deleteAll());
@@ -144,7 +143,7 @@ public class ESActiveRuleTest {
@Test
public void bulk_index_active_rules_from_ids() throws IOException {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
List<Integer> ids = newArrayList(1);
when(activeRuleDao.selectByIds(ids, session)).thenReturn(
@@ -226,8 +225,8 @@ public class ESActiveRuleTest {
List<ActiveRuleDto> activeRules = newArrayList(new ActiveRuleDto().setId(1).setProfileId(10).setRuleId(1).setSeverity(Severity.MAJOR).setParentId(5)
.setNoteData("polop").setNoteCreatedAt(new Date()).setNoteUserLogin("godin"));
- SonarSession session = mock(SonarSession.class);
- when(myBatis.openSession()).thenReturn(session);
+ DbSession session = mock(DbSession.class);
+ when(myBatis.openSession(false)).thenReturn(session);
when(activeRuleDao.selectAll(session)).thenReturn(activeRules);
when(activeRuleDao.selectAllParams(session)).thenReturn(Lists.<ActiveRuleParamDto>newArrayList());
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperationsTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperationsTest.java
index ffe2a625f97..00aefa48247 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperationsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileActiveRuleOperationsTest.java
@@ -37,8 +37,8 @@ import org.sonar.api.server.rule.RuleParamType;
import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.qualityprofile.db.ActiveRuleDao;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.qualityprofile.db.ActiveRuleParamDto;
@@ -81,7 +81,7 @@ public class QProfileActiveRuleOperationsTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
ActiveRuleDao activeRuleDao;
@@ -116,7 +116,7 @@ public class QProfileActiveRuleOperationsTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
// Associate an id when inserting an object to simulate the db id generator
doAnswer(new Answer() {
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackupTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackupTest.java
index 18bfc090784..8760c76ab90 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileBackupTest.java
@@ -38,8 +38,8 @@ import org.sonar.api.rules.Rule;
import org.sonar.api.rules.RulePriority;
import org.sonar.api.utils.ValidationMessages;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.preview.PreviewCache;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.jpa.session.DatabaseSessionFactory;
@@ -80,7 +80,7 @@ public class QProfileBackupTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
XMLProfileParser xmlProfileParser;
@@ -109,7 +109,7 @@ public class QProfileBackupTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
when(sessionFactory.getSession()).thenReturn(hibernateSession);
definitions = newArrayList();
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java
index eb6ec768182..a4840b63aaf 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileLookupTest.java
@@ -25,8 +25,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.qualityprofile.db.QualityProfileDao;
import org.sonar.core.qualityprofile.db.QualityProfileDto;
@@ -46,7 +46,7 @@ public class QProfileLookupTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
QualityProfileDao dao;
@@ -55,7 +55,7 @@ public class QProfileLookupTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
search = new QProfileLookup(myBatis, dao);
}
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileOperationsTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileOperationsTest.java
index 0e303ee0a06..8a85f570d9d 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileOperationsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileOperationsTest.java
@@ -31,8 +31,8 @@ import org.mockito.invocation.InvocationOnMock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.preview.PreviewCache;
import org.sonar.core.properties.PropertiesDao;
import org.sonar.core.properties.PropertyDto;
@@ -71,7 +71,7 @@ public class QProfileOperationsTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
QualityProfileDao qualityProfileDao;
@@ -106,7 +106,7 @@ public class QProfileOperationsTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
// Associate an id when inserting an object to simulate the db id generator
doAnswer(new Answer() {
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java
index 6755487a6fa..e2c85adfb17 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectLookupTest.java
@@ -26,8 +26,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.core.component.ComponentDto;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.properties.PropertiesDao;
import org.sonar.core.qualityprofile.db.QualityProfileDao;
import org.sonar.core.qualityprofile.db.QualityProfileDto;
@@ -46,7 +46,7 @@ public class QProfileProjectLookupTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
QualityProfileDao qualityProfileDao;
@@ -58,7 +58,7 @@ public class QProfileProjectLookupTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
lookup = new QProfileProjectLookup(myBatis, qualityProfileDao);
}
diff --git a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsTest.java b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsTest.java
index b9c46b77845..e3483259766 100644
--- a/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileProjectOperationsTest.java
@@ -28,8 +28,8 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.core.component.ComponentDto;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.properties.PropertiesDao;
import org.sonar.core.properties.PropertyDto;
import org.sonar.core.qualityprofile.db.QualityProfileDao;
@@ -55,7 +55,7 @@ public class QProfileProjectOperationsTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
QualityProfileDao qualityProfileDao;
@@ -72,7 +72,7 @@ public class QProfileProjectOperationsTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
service = new QProfileProjectOperations(myBatis, qualityProfileDao, resourceDao, propertiesDao);
}
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
index cccaf7eb462..f9dea83b3e7 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleOperationsTest.java
@@ -39,8 +39,8 @@ import org.sonar.api.utils.DateUtils;
import org.sonar.api.utils.System2;
import org.sonar.check.Cardinality;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.qualityprofile.db.ActiveRuleDao;
import org.sonar.core.qualityprofile.db.ActiveRuleDto;
import org.sonar.core.rule.RuleDao;
@@ -85,7 +85,7 @@ public class RuleOperationsTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
ActiveRuleDao activeRuleDao;
@@ -125,7 +125,7 @@ public class RuleOperationsTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
when(system.now()).thenReturn(now.getTime());
diff --git a/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java b/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java
index 1970d933b87..0d2fa7e863a 100644
--- a/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/rule/RuleRegistryTest.java
@@ -34,8 +34,8 @@ import org.mockito.runners.MockitoJUnitRunner;
import org.sonar.api.config.Settings;
import org.sonar.api.rule.RuleKey;
import org.sonar.api.rule.Severity;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.profiling.Profiling;
import org.sonar.core.rule.RuleDao;
import org.sonar.core.rule.RuleDto;
@@ -74,13 +74,13 @@ public class RuleRegistryTest {
CharacteristicDao characteristicDao;
@Mock
- SonarSession session;
+ DbSession session;
RuleRegistry registry;
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
esSetup = new EsSetup(ImmutableSettings.builder().loadFromUrl(ESNode.class.getResource("config/elasticsearch.json"))
.build());
diff --git a/sonar-server/src/test/java/org/sonar/server/source/DeprecatedSourceDecoratorTest.java b/sonar-server/src/test/java/org/sonar/server/source/DeprecatedSourceDecoratorTest.java
index a1e7da94902..9975e473815 100644
--- a/sonar-server/src/test/java/org/sonar/server/source/DeprecatedSourceDecoratorTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/source/DeprecatedSourceDecoratorTest.java
@@ -25,8 +25,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.resource.ResourceDao;
import org.sonar.core.resource.ResourceDto;
import org.sonar.core.resource.ResourceQuery;
@@ -48,7 +48,7 @@ public class DeprecatedSourceDecoratorTest {
MyBatis mybatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
ResourceDao resourceDao;
@@ -63,7 +63,7 @@ public class DeprecatedSourceDecoratorTest {
@Before
public void setUp() throws Exception {
- when(mybatis.openSession()).thenReturn(session);
+ when(mybatis.openSession(false)).thenReturn(session);
sourceDecorator = new DeprecatedSourceDecorator(mybatis, resourceDao, codeColorizers, snapshotSourceDao);
}
diff --git a/sonar-server/src/test/java/org/sonar/server/startup/RegisterQualityProfilesTest.java b/sonar-server/src/test/java/org/sonar/server/startup/RegisterQualityProfilesTest.java
index 52419ba6318..028d50a85bf 100644
--- a/sonar-server/src/test/java/org/sonar/server/startup/RegisterQualityProfilesTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/startup/RegisterQualityProfilesTest.java
@@ -31,8 +31,8 @@ import org.sonar.api.profiles.ProfileDefinition;
import org.sonar.api.profiles.RulesProfile;
import org.sonar.api.utils.SonarException;
import org.sonar.api.utils.ValidationMessages;
+import org.sonar.core.persistence.DbSession;
import org.sonar.core.persistence.MyBatis;
-import org.sonar.core.persistence.SonarSession;
import org.sonar.core.qualityprofile.db.QualityProfileDao;
import org.sonar.core.template.LoadedTemplateDao;
import org.sonar.core.template.LoadedTemplateDto;
@@ -85,7 +85,7 @@ public class RegisterQualityProfilesTest {
MyBatis myBatis;
@Mock
- SonarSession session;
+ DbSession session;
@Mock
DatabaseSessionFactory sessionFactory;
@@ -99,7 +99,7 @@ public class RegisterQualityProfilesTest {
@Before
public void setUp() throws Exception {
- when(myBatis.openSession()).thenReturn(session);
+ when(myBatis.openSession(false)).thenReturn(session);
when(sessionFactory.getSession()).thenReturn(mock(DatabaseSession.class));
definitions = newArrayList();