aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main/java
diff options
context:
space:
mode:
authorsimonbrandhof <simon.brandhof@gmail.com>2010-10-21 15:05:41 +0000
committersimonbrandhof <simon.brandhof@gmail.com>2010-10-21 15:05:41 +0000
commita21b4ac84deb666976e87f6a823d60eb977449e2 (patch)
tree2b227d2f798be768bd734eeae4620eb91765d165 /sonar-server/src/main/java
parenta16fe9d1448070c61f8eb7d43369643b666cf71b (diff)
downloadsonarqube-a21b4ac84deb666976e87f6a823d60eb977449e2.tar.gz
sonarqube-a21b4ac84deb666976e87f6a823d60eb977449e2.zip
SONAR-1881 delete ActiveRule orphans when restoring a global conf backup
Diffstat (limited to 'sonar-server/src/main/java')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java
index d5143a5ebf1..aea09e1cf01 100644
--- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java
+++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesManager.java
@@ -27,6 +27,8 @@ import org.sonar.api.rules.DefaultRulesManager;
import org.sonar.jpa.dao.BaseDao;
import org.sonar.jpa.dao.RulesDao;
+import java.util.List;
+
public class ProfilesManager extends BaseDao {
private DefaultRulesManager rulesManager;
@@ -63,7 +65,10 @@ public class ProfilesManager extends BaseDao {
public void deleteAllProfiles() {
getSession().createQuery("UPDATE " + ResourceModel.class.getSimpleName() + " o SET o.rulesProfile = null WHERE o.rulesProfile IS NOT NULL").executeUpdate();
- getSession().createQuery("DELETE " + RulesProfile.class.getSimpleName() + " o").executeUpdate();
+ List profiles = getSession().createQuery("FROM " + RulesProfile.class.getSimpleName()).getResultList();
+ for (Object profile : profiles) {
+ getSession().removeWithoutFlush(profile);
+ }
getSession().commit();
}