]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1929 Fix problem with MyBatis on Oracle
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 14 Dec 2011 13:59:45 +0000 (14:59 +0100)
committerFabrice Bellingard <bellingard@gmail.com>
Wed, 14 Dec 2011 14:10:52 +0000 (15:10 +0100)
sonar-core/src/main/resources/org/sonar/persistence/model/ActiveDashboardMapper-oracle.xml
sonar-core/src/main/resources/org/sonar/persistence/model/DashboardMapper-oracle.xml
sonar-core/src/main/resources/org/sonar/persistence/model/LoadedTemplateMapper-oracle.xml
sonar-core/src/main/resources/org/sonar/persistence/model/WidgetMapper-oracle.xml
sonar-core/src/test/resources/org/sonar/persistence/dao/DashboardDaoTest/shouldInsert-result.xml
sonar-core/src/test/resources/org/sonar/persistence/dao/DashboardDaoTest/shouldInsertWithNullableColumns-result.xml

index 2bfb90f8e45b8dc9357c8cfab2ef33dd8baa06d5..a03aa4c2b1310a887f6799ca446ea3ebda38da94 100644 (file)
@@ -3,9 +3,12 @@
 
 <mapper namespace="org.sonar.persistence.model.ActiveDashboardMapper">
 
-  <insert id="insert" parameterType="ActiveDashboard" keyColumn="id" useGeneratedKeys="false" keyProperty ="id">
+  <insert id="insert" parameterType="ActiveDashboard" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
+    <selectKey order="BEFORE" resultType="Long" keyProperty="id" >
+        select active_dashboards_seq.NEXTVAL from DUAL
+    </selectKey>
     INSERT INTO active_dashboards (id, dashboard_id, user_id, order_index)
-    VALUES (active_dashboards_seq.NEXTVAL, #{dashboardId}, #{userId, jdbcType=FLOAT}, #{orderIndex})
+    VALUES (#{id}, #{dashboardId}, #{userId, jdbcType=FLOAT}, #{orderIndex})
   </insert>
 
   <select id="selectMaxOrderIndexForNullUser" resultType="Integer">
index 9ecb62c0b7de59fea5f35505e066edb3a36c22df..6bdc37cac9d103e3f406c2f6552bd3fa0d4b32bd 100644 (file)
@@ -3,9 +3,12 @@
 
 <mapper namespace="org.sonar.persistence.model.DashboardMapper">
 
-  <insert id="insert" parameterType="Dashboard" keyColumn="id" useGeneratedKeys="false" keyProperty ="id">
+  <insert id="insert" parameterType="Dashboard" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
+    <selectKey order="BEFORE" resultType="Long" keyProperty="id" >
+        select dashboards_seq.NEXTVAL from DUAL
+    </selectKey>
     INSERT INTO dashboards (id, kee, user_id, name, description, column_layout, shared, created_at, updated_at)
-    VALUES (dashboards_seq.NEXTVAL, #{key}, #{userId, jdbcType=FLOAT}, #{name, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, 
+    VALUES (#{id}, #{key}, #{userId, jdbcType=FLOAT}, #{name, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, 
             #{columnLayout, jdbcType=INTEGER}, #{shared}, #{createdAt, jdbcType=TIMESTAMP}, #{updatedAt, jdbcType=TIMESTAMP})
   </insert>
 
index 071898d2af841e4cdc8a76d8e1279d574bbf3e76..f6af7c06b64dc4a051fb9f0db05c812134924f0c 100644 (file)
@@ -6,18 +6,21 @@
   <resultMap id="loadedTemplateResultMap" type="LoadedTemplate">
     <result property="id" column="id"/>
     <result property="key" column="kee"/>
-    <result property="type" column="type"/>
+    <result property="type" column="template_type"/>
   </resultMap>
 
-  <select id="selectByKeyAndType" parameterType="map" resultType="LoadedTemplate">
+  <select id="selectByKeyAndType" parameterType="map" resultMap="loadedTemplateResultMap">
     SELECT id, kee, template_type 
     FROM loaded_templates 
     WHERE kee = #{key} AND template_type = #{type}
   </select>
 
-  <insert id="insert" parameterType="LoadedTemplate" keyColumn="id" useGeneratedKeys="false" keyProperty ="id">
+  <insert id="insert" parameterType="LoadedTemplate" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
+    <selectKey order="BEFORE" resultType="Long" keyProperty="id" >
+        select loaded_templates_seq.NEXTVAL from DUAL
+    </selectKey>
     INSERT INTO loaded_templates (id, kee, template_type)
-    VALUES (loaded_templates.NEXTVAL, #{key}, #{type})
+    VALUES (#{id}, #{key}, #{type})
   </insert>
 
 </mapper>
index c6602d5179a1d4d7abb3b6cd5ad79a741a0bcc85..7c9891c21be81b493c9d9ca609501985db711a7e 100644 (file)
@@ -3,9 +3,12 @@
 
 <mapper namespace="org.sonar.persistence.model.WidgetMapper">
 
-  <insert id="insert" parameterType="Widget" keyColumn="id" useGeneratedKeys="false" keyProperty ="id">
+  <insert id="insert" parameterType="Widget" keyColumn="id" useGeneratedKeys="true" keyProperty ="id">
+    <selectKey order="BEFORE" resultType="Long" keyProperty="id" >
+        select widgets_seq.NEXTVAL from DUAL
+    </selectKey>
     INSERT INTO widgets (id, dashboard_id, widget_key, name, description, column_index, row_index, configured, created_at, updated_at)
-    VALUES (widgets_seq.NEXTVAL, #{dashboardId}, #{key}, #{name, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, #{columnIndex, jdbcType=INTEGER}, 
+    VALUES (#{id}, #{dashboardId}, #{key}, #{name, jdbcType=VARCHAR}, #{description, jdbcType=VARCHAR}, #{columnIndex, jdbcType=INTEGER}, 
             #{rowIndex, jdbcType=INTEGER}, #{configured}, #{createdAt, jdbcType=TIMESTAMP}, #{updatedAt, jdbcType=TIMESTAMP})
   </insert>
 
index 5f4e92ddd8014c03c56e6a76ef8bc085fc828874..9515145dcceae08fb9f033cb9884ebc5c2eb6a70 100644 (file)
@@ -7,7 +7,7 @@
       name="My Dashboard"
       description="This is a dashboard"
       column_layout="100%"
-      shared="true"/>
+      shared="1"/>
 
   <widgets
       id="1"
@@ -17,7 +17,7 @@
       description="Widget for code coverage"
       column_index="13"
       row_index="14"
-      configured="true"/>
+      configured="1"/>
 
   <widget_properties
       id="1"
index 158c1fd610d91be3fc5047b661b6c49ded208efb..729b5deef895c272862cdbbb3a6467788891ae96 100644 (file)
@@ -7,7 +7,7 @@
       name="[null]"
       description="[null]"
       column_layout="[null]"
-      shared="true"
+      shared="1"
       created_at="[null]"
       updated_at="[null]"/>
 
@@ -19,7 +19,7 @@
       description="[null]"
       column_index="[null]"
       row_index="[null]"
-      configured="true"
+      configured="1"
       created_at="[null]"
       updated_at="[null]"/>