]> source.dussan.org Git - sonarqube.git/commitdiff
Make sure MyBatis is not configured to use generated keys in batch inserts
authorDavid Gageot <david@gageot.net>
Tue, 10 Jul 2012 14:52:14 +0000 (16:52 +0200)
committerDavid Gageot <david@gageot.net>
Tue, 10 Jul 2012 14:52:14 +0000 (16:52 +0200)
Fix for Oracle

sonar-core/src/main/java/org/sonar/core/persistence/BatchSession.java

index 1b7300184831a8f3707182c348981de4ab83ef96..d7f7211feb9ae66aa0b028bc1dc8d6f3d2dee61a 100644 (file)
@@ -20,8 +20,8 @@
 package org.sonar.core.persistence;
 
 import org.apache.ibatis.executor.BatchResult;
+import org.apache.ibatis.executor.keygen.Jdbc3KeyGenerator;
 import org.apache.ibatis.executor.keygen.KeyGenerator;
-import org.apache.ibatis.executor.keygen.NoKeyGenerator;
 import org.apache.ibatis.mapping.MappedStatement;
 import org.apache.ibatis.session.Configuration;
 import org.apache.ibatis.session.ResultHandler;
@@ -122,7 +122,7 @@ public final class BatchSession implements SqlSession {
       MappedStatement mappedStatement = configuration.getMappedStatement(statement);
       if (null != mappedStatement) {
         KeyGenerator keyGenerator = mappedStatement.getKeyGenerator();
-        if (!(keyGenerator instanceof NoKeyGenerator)) {
+        if (keyGenerator instanceof Jdbc3KeyGenerator) {
           throw new IllegalStateException("Batch updates cannot use generated keys");
         }
       }