]> source.dussan.org Git - sonarqube.git/commitdiff
Add MyBatis RoleMapper for Oracle
authorSimon Brandhof <simon.brandhof@gmail.com>
Fri, 6 Jul 2012 07:27:14 +0000 (09:27 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Fri, 6 Jul 2012 07:27:14 +0000 (09:27 +0200)
sonar-core/src/main/resources/org/sonar/core/user/RoleMapper-oracle.xml [new file with mode: 0644]

diff --git a/sonar-core/src/main/resources/org/sonar/core/user/RoleMapper-oracle.xml b/sonar-core/src/main/resources/org/sonar/core/user/RoleMapper-oracle.xml
new file mode 100644 (file)
index 0000000..e77b822
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="org.sonar.core.user.RoleMapper">
+
+  <insert id="insertGroupRole" parameterType="GroupRole" useGeneratedKeys="true" keyProperty="id">
+    <selectKey order="BEFORE" resultType="Long" keyProperty="id">
+      select group_roles_seq.NEXTVAL from DUAL
+    </selectKey>
+    INSERT INTO group_roles (id, group_id, resource_id, role)
+    VALUES (#{id}, #{groupId, jdbcType=INTEGER}, #{resourceId, jdbcType=INTEGER}, #{role, jdbcType=VARCHAR})
+  </insert>
+
+  <insert id="insertUserRole" parameterType="UserRole" useGeneratedKeys="true" keyProperty="id">
+    <selectKey order="BEFORE" resultType="Long" keyProperty="id">
+      select user_roles_seq.NEXTVAL from DUAL
+    </selectKey>
+    INSERT INTO user_roles (id, user_id, resource_id, role)
+    VALUES (#{id}, #{userId, jdbcType=INTEGER}, #{resourceId, jdbcType=INTEGER}, #{role, jdbcType=VARCHAR})
+  </insert>
+
+  <delete id="deleteGroupRolesByResourceId" parameterType="long">
+    delete from group_roles where resource_id=#{id}
+  </delete>
+
+  <delete id="deleteUserRolesByResourceId" parameterType="long">
+    delete from user_roles where resource_id=#{id}
+  </delete>
+
+  <select id="countUserRoles" parameterType="long" resultType="int">
+    SELECT count(id)
+    FROM user_roles WHERE resource_id=#{id}
+  </select>
+
+  <select id="countGroupRoles" parameterType="long" resultType="int">
+    SELECT count(id)
+    FROM group_roles WHERE resource_id=#{id}
+  </select>
+</mapper>