]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3287 fix compatibility with Oracle
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 21 Nov 2012 08:49:45 +0000 (09:49 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 21 Nov 2012 08:49:45 +0000 (09:49 +0100)
sonar-core/src/main/java/org/sonar/core/persistence/SemaphoreDto.java
sonar-core/src/main/resources/org/sonar/core/persistence/SemaphoreMapper.xml

index 01f84aa3902db29e694dadcfb67cd5be61550d92..77434345069fe76ce177cab8d8dc22dbd76540bc 100644 (file)
@@ -27,6 +27,7 @@ import java.util.Date;
  * @since 3.4
  */
 public class SemaphoreDto {
+  private Long id;
   private String name;
   private String checksum;
   private Date lockedAt;
@@ -49,4 +50,13 @@ public class SemaphoreDto {
     this.lockedAt = d;
     return this;
   }
+
+  public Long getId() {
+    return id;
+  }
+
+  public SemaphoreDto setId(Long id) {
+    this.id = id;
+    return this;
+  }
 }
index bd56b88be1c33302ddc1d9b920fa02843e77c510..cf824381d16ee531fd2a13fedc37d4b6db50e283 100644 (file)
@@ -8,10 +8,22 @@
     VALUES (#{name}, #{checksum}, current_timestamp, current_timestamp, #{lockedAt})
   </insert>
 
+  <insert id="initialize" databaseId="oracle" parameterType="map" useGeneratedKeys="false">
+    <selectKey order="BEFORE" resultType="Long" keyProperty="id">
+      select semaphores_seq.NEXTVAL from DUAL
+    </selectKey>
+    INSERT INTO semaphores (id, name, checksum, created_at, updated_at, locked_at)
+    VALUES (#{id}, #{name}, #{checksum}, current_timestamp, current_timestamp, #{lockedAt})
+  </insert>
+
   <select id="now" resultType="Date">
     select current_timestamp
   </select>
 
+  <select id="now" databaseId="oracle" resultType="Date">
+    select current_timestamp from dual
+  </select>
+
   <update id="acquire" parameterType="map">
     update semaphores
     set updated_at = current_timestamp, locked_at = current_timestamp