diff options
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java index 76a59f8ea80..4c93ba8f977 100644 --- a/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java +++ b/sonar-core/src/main/java/org/sonar/core/rule/CacheRuleFinder.java @@ -23,6 +23,7 @@ import com.google.common.collect.BiMap; import com.google.common.collect.HashBiMap; import com.google.common.collect.Maps; import org.apache.commons.lang.StringUtils; +import org.hibernate.Hibernate; import org.sonar.api.database.DatabaseSession; import org.sonar.api.rule.RuleKey; import org.sonar.api.rules.Rule; @@ -32,6 +33,7 @@ import org.sonar.jpa.session.DatabaseSessionFactory; import javax.annotation.CheckForNull; import javax.persistence.Query; + import java.util.Collection; import java.util.HashMap; import java.util.Map; @@ -72,6 +74,7 @@ public final class CacheRuleFinder implements RuleFinder { rulesByKey.put(repositoryKey, repository); for (Rule rule : findAll(RuleQuery.create().withRepositoryKey(repositoryKey))) { + hibernateHack(rule); repository.put(rule.getKey(), rule); rulesById.put(rule.getId(), rule); } @@ -79,6 +82,10 @@ public final class CacheRuleFinder implements RuleFinder { return repository; } + private void hibernateHack(Rule rule) { + Hibernate.initialize(rule.getParams()); + } + protected final Rule doFindById(int ruleId) { DatabaseSession session = sessionFactory.getSession(); return session.getSingleResult( @@ -89,7 +96,6 @@ public final class CacheRuleFinder implements RuleFinder { null); } - @Override @CheckForNull public Rule findByKey(RuleKey key) { |