]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5606 refactor MyBatis configuration of result set scrolling
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 31 Oct 2014 08:24:49 +0000 (09:24 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Fri, 31 Oct 2014 08:54:23 +0000 (09:54 +0100)
server/sonar-server/src/main/java/org/sonar/server/db/migrations/SelectImpl.java
server/sonar-server/src/test/resources/org/sonar/server/db/fake/FakeMapper.xml
sonar-core/src/main/java/org/sonar/core/persistence/dialect/Dialect.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueAuthorizationMapper.xml
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
sonar-core/src/main/resources/org/sonar/core/qualityprofile/db/ActiveRuleMapper.xml
sonar-core/src/main/resources/org/sonar/core/rule/RuleMapper.xml

index b49fc88edee07aba640a4af55da644521cd3bd64..11243866258fb84a61d1604f7694609928a621ed 100644 (file)
@@ -21,7 +21,6 @@ package org.sonar.server.db.migrations;
 
 import org.apache.commons.dbutils.DbUtils;
 import org.sonar.core.persistence.Database;
-import org.sonar.core.persistence.dialect.MySql;
 
 import java.sql.Connection;
 import java.sql.PreparedStatement;
@@ -83,11 +82,7 @@ class SelectImpl extends BaseSqlStatement<Select> implements Select {
 
   static SelectImpl create(Database db, Connection connection, String sql) throws SQLException {
     PreparedStatement pstmt = connection.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
-    if (db.getDialect().getId().equals(MySql.ID)) {
-      pstmt.setFetchSize(Integer.MIN_VALUE);
-    } else {
-      pstmt.setFetchSize(1000);
-    }
+    pstmt.setFetchSize(db.getDialect().getScrollDefaultFetchSize());
     return new SelectImpl(pstmt);
   }
 }
index 3ab38789b2de035259fff643a4d9c43d9c0a3326..ade408763326f9320bd4aa83460d18655b5f4d7f 100644 (file)
@@ -21,7 +21,7 @@
     values (#{key}, #{createdAt}, #{updatedAt})
   </insert>
 
-  <select id="selectAfterDate" resultType="fake" resultSetType="FORWARD_ONLY" fetchSize="200">
+  <select id="selectAfterDate" resultType="fake" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
     select
     <include refid="selectColumns"/>
     from fake f
index e0061b20bf9ae73d455b5939c709b13ee41c4e86..ffaae93959f6bd310ea7b34b8980dc76f5a7c29f 100644 (file)
@@ -73,5 +73,10 @@ public interface Dialect {
    */
   String getValidationQuery();
 
+  /**
+   * Fetch size to be used when scrolling large result sets.
+   *
+   * @since 5.0
+   */
   int getScrollDefaultFetchSize();
 }
index 90cff28939b5eae0c2a37953ccfd8550282d1278..5b2def86db38ec966d9fa30c5910853c42c64131 100644 (file)
@@ -12,7 +12,8 @@
     <result property="updatedAt" column="updatedAt" javaType="java.util.Date"/>
   </resultMap>
 
-  <select id="selectAfterDate" parameterType="map" resultMap="resultMap">
+  <select id="selectAfterDate" parameterType="map" resultMap="resultMap"
+          fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
     SELECT
       project_authorization.project as "project",
       project_authorization.login as "permissionUser",
index 4c751b3e87704ab6f3f5824a2d86b79f2a10e488..b781a3ff96282d9952c868595d0931e818ee6f67 100644 (file)
     where i.kee=#{kee}
   </select>
 
-  <select id="selectAfterDate" resultType="Issue"
-          fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
+  <select id="selectAfterDate" resultType="Issue" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
     select
     <include refid="issueColumns"/>
     from issues i
index a99c19cb97873c9ee1d2b5ecf716625c4c807492..0775c410de8d5f094e927333d8d87b43e4a52fe7 100644 (file)
@@ -39,7 +39,8 @@
     LEFT JOIN active_rules active_rule_parent ON active_rule_parent.profile_id=profile_parent.id AND a.rule_id=active_rule_parent.rule_id
   </sql>
 
-  <select id="selectAfterDate" parameterType="Date" resultType="ActiveRule" resultSetType="FORWARD_ONLY">
+  <select id="selectAfterDate" parameterType="Date" resultType="ActiveRule"
+          fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
     select
     <include refid="activeRuleKeyColumns"/>
     from active_rules a
index ed20d1e06810870e83cc47d043ba971708233dea..282f79c10582111188a91052bf5f7dcc195d5c95 100644 (file)
@@ -41,7 +41,7 @@
     from rules r
   </select>
 
-  <select id="selectAfterDate" resultType="Rule" resultSetType="FORWARD_ONLY" fetchSize="200">
+  <select id="selectAfterDate" resultType="Rule" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
     select
     <include refid="selectColumns"/>
     from rules r