From: Julien Lancelot Date: Tue, 28 Oct 2014 14:25:17 +0000 (+0100) Subject: SONAR-5755 Read projects in cursor mode X-Git-Tag: 5.0-RC1~533 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d7f9f5b2cd131f2a203a8c742b7e787c822677eb;p=sonarqube.git SONAR-5755 Read projects in cursor mode --- diff --git a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java index e5ad598c6bb..67173b47e1e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java +++ b/server/sonar-server/src/main/java/org/sonar/server/db/migrations/v50/PopulateProjectsUuidColumnsMigration.java @@ -22,6 +22,8 @@ package org.sonar.server.db.migrations.v50; import com.google.common.base.Splitter; import com.google.common.base.Strings; +import org.apache.ibatis.session.ResultContext; +import org.apache.ibatis.session.ResultHandler; import org.sonar.api.resources.Scopes; import org.sonar.core.persistence.DbSession; import org.sonar.core.persistence.migration.v50.Component; @@ -59,21 +61,23 @@ public class PopulateProjectsUuidColumnsMigration implements DatabaseMigration { Timer timer = new Timer("Db Migration Progress"); timer.schedule(progressTask, MassUpdate.ProgressTask.PERIOD_MS, MassUpdate.ProgressTask.PERIOD_MS); - DbSession session = db.openSession(true); + final DbSession session = db.openSession(true); try { - Migration50Mapper mapper = session.getMapper(Migration50Mapper.class); - - for (Component project : mapper.selectRootProjects()) { - Map uuidByComponentId = newHashMap(); - migrateEnabledComponents(session, mapper, project, uuidByComponentId); - migrateDisabledComponents(session, mapper, project, uuidByComponentId); - } + final Migration50Mapper mapper = session.getMapper(Migration50Mapper.class); + session.select("org.sonar.core.persistence.migration.v50.Migration50Mapper.selectRootProjects", new ResultHandler() { + @Override + public void handleResult(ResultContext context) { + Component project = (Component) context.getResultObject(); + Map uuidByComponentId = newHashMap(); + migrateEnabledComponents(session, mapper, project, uuidByComponentId); + migrateDisabledComponents(session, mapper, project, uuidByComponentId); + } + }); migrateComponentsWithoutUuid(session, mapper); session.commit(); // log the total number of process rows progressTask.log(); - } finally { session.close(); timer.cancel();