aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-23 22:10:19 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-01-24 09:39:30 +0100
commit6a5780a742414656a278a53813d65e47102b2310 (patch)
tree4b81b2020dc35bb4276ae9ead8abe19dc5ab8518 /sonar-db
parent8f37914e061783a4a32445b5238e8fa37666aaef (diff)
downloadsonarqube-6a5780a742414656a278a53813d65e47102b2310.tar.gz
sonarqube-6a5780a742414656a278a53813d65e47102b2310.zip
Add some missing jdbcType attributes to MyBatis mappers
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ComponentKeyUpdaterMapper.xml22
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ComponentLinkMapper.xml21
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml107
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml38
4 files changed, 90 insertions, 98 deletions
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentKeyUpdaterMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentKeyUpdaterMapper.xml
index 2a98c2cdad2..4514ad12014 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentKeyUpdaterMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentKeyUpdaterMapper.xml
@@ -16,25 +16,35 @@
<select id="countResourceByKey" parameterType="String" resultType="int">
SELECT count(1)
FROM projects
- WHERE kee = #{key}
+ WHERE kee = #{key,jdbcType=VARCHAR}
</select>
<select id="selectProject" parameterType="String" resultMap="resourceResultMap">
- select * from projects where uuid=#{uuid}
+ select * from projects
+ where uuid=#{uuid,jdbcType=VARCHAR}
</select>
<select id="selectProjectResources" parameterType="String" resultMap="resourceResultMap">
- select * from projects where root_uuid=#{rootUuid} AND scope!='PRJ' and enabled=${_true}
+ select * from projects
+ where
+ root_uuid=#{rootUuid,jdbcType=VARCHAR}
+ and scope!='PRJ'
+ and enabled=${_true}
</select>
<select id="selectDescendantProjects" parameterType="String" resultMap="resourceResultMap">
- select * from projects where scope='PRJ' and root_uuid=#{rootUuid} and uuid!=#{rootUuid} and enabled=${_true}
+ select * from projects
+ where
+ scope='PRJ'
+ and root_uuid = #{rootUuid,jdbcType=VARCHAR}
+ and uuid != #{rootUuid,jdbcType=VARCHAR}
+ and enabled = ${_true}
</select>
<update id="update" parameterType="Resource">
update projects
- set kee = #{key}, deprecated_kee = #{deprecatedKey}
- where id = #{id}
+ set kee = #{key,jdbcType=VARCHAR}, deprecated_kee = #{deprecatedKey,jdbcType=VARCHAR}
+ where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentLinkMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentLinkMapper.xml
index d74de88a667..1b9ba17cba6 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentLinkMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentLinkMapper.xml
@@ -14,9 +14,7 @@
SELECT
<include refid="componentLinkColumns"/>
FROM project_links p
- <where>
- AND p.component_uuid=#{uuid}
- </where>
+ where p.component_uuid=#{uuid,jdbcType=VARCHAR}
ORDER BY p.id
</select>
@@ -24,22 +22,19 @@
SELECT
<include refid="componentLinkColumns"/>
FROM project_links p
- <where>
- AND p.component_uuid in
+ where
+ p.component_uuid in
<foreach collection="componentUuids" open="(" close=")" item="uuid" separator=",">
- #{uuid}
+ #{uuid,jdbcType=VARCHAR}
</foreach>
- </where>
order by p.id
</select>
- <select id="selectById" parameterType="String" resultType="ComponentLink">
+ <select id="selectById" parameterType="long" resultType="ComponentLink">
SELECT
<include refid="componentLinkColumns"/>
FROM project_links p
- <where>
- p.id=#{id}
- </where>
+ where p.id=#{id,jdbcType=BIGINT}
</select>
<insert id="insert" parameterType="ComponentLink" keyColumn="id" useGeneratedKeys="true" keyProperty="id">
@@ -51,11 +46,11 @@
<insert id="update" parameterType="ComponentLink" useGeneratedKeys="false">
UPDATE project_links SET component_uuid=#{componentUuid,jdbcType=VARCHAR}, link_type=#{type,jdbcType=VARCHAR},
name=#{name,jdbcType=VARCHAR}, href=#{href,jdbcType=VARCHAR}
- WHERE id=#{id}
+ WHERE id=#{id,jdbcType=BIGINT}
</insert>
<delete id="delete">
- DELETE FROM project_links WHERE id=#{id}
+ DELETE FROM project_links WHERE id=#{id,jdbcType=BIGINT}
</delete>
</mapper>
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
index 2f4a42d2835..5813d2aca3b 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/ComponentMapper.xml
@@ -32,26 +32,22 @@
<include refid="componentColumns"/>
FROM projects p
where
- p.kee=#{key}
+ p.kee=#{key,jdbcType=VARCHAR}
</select>
<select id="selectComponentsHavingSameKeyOrderedById" parameterType="String" resultType="Component">
- SELECT
+ select
<include refid="componentColumns"/>
- FROM projects p
- <where>
- AND p.kee=#{key}
- </where>
- ORDER BY p.id ASC
+ from projects p
+ where p.kee=#{key,jdbcType=VARCHAR}
+ order BY p.id ASC
</select>
<select id="selectById" parameterType="long" resultType="Component">
SELECT
<include refid="componentColumns"/>
FROM projects p
- <where>
- AND p.id=#{id}
- </where>
+ where p.id = #{id,jdbcType=BIGINT}
</select>
<select id="selectByUuid" parameterType="String" resultType="Component">
@@ -59,7 +55,7 @@
<include refid="componentColumns"/>
FROM projects p
where
- p.uuid=#{uuid}
+ p.uuid=#{uuid,jdbcType=VARCHAR}
</select>
<select id="selectByProjectUuid" parameterType="string" resultType="Component">
@@ -68,33 +64,31 @@
from projects root
inner join projects p on p.project_uuid=root.uuid and p.organization_uuid=root.organization_uuid
where
- root.uuid=#{projectUuid}
+ root.uuid=#{projectUuid,jdbcType=VARCHAR}
</select>
<select id="selectByKeys" parameterType="String" resultType="Component">
select
<include refid="componentColumns"/>
from projects p
- <where>
+ where
p.enabled=${_true}
and p.kee in
<foreach collection="keys" open="(" close=")" item="key" separator=",">
- #{key}
+ #{key,jdbcType=VARCHAR}
</foreach>
- </where>
</select>
<select id="selectByIds" parameterType="long" resultType="Component">
select
<include refid="componentColumns"/>
from projects p
- <where>
+ where
p.enabled=${_true}
and p.id in
<foreach collection="ids" open="(" close=")" item="id" separator=",">
- #{id}
+ #{id,jdbcType=BIGINT}
</foreach>
- </where>
</select>
<select id="selectByUuids" parameterType="String" resultType="Component">
@@ -104,19 +98,18 @@
where
p.uuid in
<foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid}
+ #{uuid,jdbcType=VARCHAR}
</foreach>
</select>
<select id="selectExistingUuids" parameterType="String" resultType="String">
select p.uuid
from projects p
- <where>
- and p.uuid in
+ where
+ p.uuid in
<foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid}
+ #{uuid,jdbcType=VARCHAR}
</foreach>
- </where>
</select>
<select id="selectSubProjectsByComponentUuids" parameterType="String" resultType="Component">
@@ -132,7 +125,7 @@
and p.scope='PRJ'
and child.uuid in
<foreach collection="uuids" open="(" close=")" item="uuid" separator=",">
- #{uuid}
+ #{uuid,jdbcType=VARCHAR}
</foreach>
</select>
@@ -149,12 +142,12 @@
and module.organization_uuid = p.organization_uuid
and module.uuid = #{moduleUuid}
and module.scope='PRJ' AND module.enabled = ${_true}
- <where>
+ where
+ p.scope = #{scope,jdbcType=VARCHAR}
<if test="excludeDisabled">
- p.enabled = ${_true}
+ and p.enabled = ${_true}
</if>
- AND p.scope = #{scope}
- AND
+ and
<choose>
<when test="_databaseId == 'mssql'">
p.module_uuid_path LIKE module.module_uuid_path + '%'
@@ -166,7 +159,6 @@
p.module_uuid_path LIKE module.module_uuid_path || '%'
</otherwise>
</choose>
- </where>
</sql>
<select id="selectEnabledFilesFromProject" parameterType="map" resultType="FilePathWithHash">
@@ -186,7 +178,7 @@
fs.file_uuid=p.uuid
and fs.data_type='SOURCE'
where
- root.uuid=#{projectUuid}
+ root.uuid=#{projectUuid,jdbcType=VARCHAR}
</select>
<select id="selectDescendantFiles" parameterType="map" resultType="FilePathWithHash">
@@ -207,11 +199,10 @@
select
<include refid="componentColumns"/>
from projects p
- <where>
+ where
p.enabled=${_true}
AND p.scope='PRJ'
AND p.qualifier='TRK'
- </where>
</select>
<select id="selectAllRootsByOrganization" resultType="Component">
@@ -228,11 +219,10 @@
SELECT
<include refid="componentColumns"/>
FROM projects p
- <where>
+ where
<foreach collection="qualifiers" open="(" close=")" item="qualifier" separator="OR ">
- p.qualifier=#{qualifier}
+ p.qualifier=#{qualifier,jdbcType=VARCHAR}
</foreach>
- </where>
</select>
<select id="selectByQuery" resultType="Component">
@@ -255,21 +245,21 @@
<if test="query.qualifiers!=null">
AND p.qualifier in
<foreach collection="query.qualifiers" item="qualifier" open="(" close=")" separator=",">
- #{qualifier}
+ #{qualifier,jdbcType=VARCHAR}
</foreach>
</if>
<if test="query.language!=null">
- AND p.language = #{query.language}
+ AND p.language = #{query.language,jdbcType=VARCHAR}
</if>
<if test="query.componentIds!=null">
AND p.id in
<foreach collection="query.componentIds" item="componentId" open="(" close=")" separator=",">
- #{componentId}
+ #{componentId,jdbcType=BIGINT}
</foreach>
</if>
<if test="query.nameOrKeyQuery!=null">
AND (
- p.kee=#{query.nameOrKeyQuery}
+ p.kee=#{query.nameOrKeyQuery,jdbcType=VARCHAR}
OR
p.uuid IN (
SELECT ri.component_uuid
@@ -278,7 +268,7 @@
<if test="query.qualifiers!=null">
AND ri.qualifier in
<foreach collection="query.qualifiers" item="qualifier" open="(" close=")" separator=",">
- #{qualifier}
+ #{qualifier,jdbcType=VARCHAR}
</foreach>
</if>
)
@@ -300,10 +290,10 @@
inner join projects base on base.project_uuid = p.project_uuid and base.uuid = #{baseUuid}
<choose>
<when test="query.getStrategy().name() == 'CHILDREN'">
- and p.uuid_path = #{baseUuidPath}
+ and p.uuid_path = #{baseUuidPath,jdbcType=VARCHAR}
</when>
<otherwise>
- and p.uuid_path like #{baseUuidPath} ESCAPE '/'
+ and p.uuid_path like #{baseUuidPath,jdbcType=VARCHAR} ESCAPE '/'
</otherwise>
</choose>
</sql>
@@ -313,7 +303,7 @@
<if test="query.qualifiers != null">
and p.qualifier in
<foreach collection="query.qualifiers" item="qualifier" open="(" close=")" separator=",">
- #{qualifier}
+ #{qualifier,jdbcType=VARCHAR}
</foreach>
</if>
<if test="query.nameOrKeyQuery != null">
@@ -337,33 +327,32 @@
<select id="selectUuidsForQualifiers" resultType="UuidWithProjectUuid">
SELECT p.uuid as "uuid", p.project_uuid as "projectUuid" FROM projects p
- <where>
+ where
<foreach collection="qualifiers" open="(" close=")" item="qualifier" separator="OR ">
- p.qualifier=#{qualifier}
+ p.qualifier=#{qualifier,jdbcType=VARCHAR}
</foreach>
- </where>
</select>
<select id="selectProjectsFromView" resultType="String">
SELECT p.uuid FROM projects technical_projects
INNER JOIN projects p on p.uuid=technical_projects.copy_component_uuid AND p.enabled=${_true}
- <where>
- technical_projects.enabled=${_true} AND technical_projects.project_uuid=#{projectViewUuid}
- AND technical_projects.module_uuid_path LIKE #{viewUuidLikeQuery}
- </where>
+ where
+ technical_projects.enabled=${_true}
+ AND technical_projects.project_uuid = #{projectViewUuid,jdbcType=VARCHAR}
+ AND technical_projects.module_uuid_path LIKE #{viewUuidLikeQuery,jdbcType=VARCHAR}
</select>
<select id="selectComponentsFromProjectKeyAndScope" parameterType="map" resultType="Component">
SELECT
<include refid="componentColumns"/>
FROM projects p
- INNER JOIN projects root ON root.uuid=p.project_uuid AND root.kee=#{projectKey}
+ INNER JOIN projects root ON root.uuid=p.project_uuid AND root.kee=#{projectKey,jdbcType=VARCHAR}
<where>
<if test="excludeDisabled">
p.enabled = ${_true}
</if>
<if test="scope != null">
- AND p.scope=#{scope}
+ AND p.scope=#{scope,jdbcType=VARCHAR}
</if>
</where>
</select>
@@ -414,7 +403,7 @@
left join snapshots s2 on s2.component_uuid = p.uuid and s2.status='P'
where
s2.id is null
- and p.qualifier=#{qualifier}
+ and p.qualifier=#{qualifier,jdbcType=VARCHAR}
and p.copy_component_uuid is null
<if test="query!=null">
and (
@@ -432,7 +421,7 @@
p.enabled=${_true}
and p.copy_component_uuid is null
<if test="projectUuid != null">
- and p.project_uuid=#{projectUuid}
+ and p.project_uuid=#{projectUuid,jdbcType=VARCHAR}
</if>
</select>
@@ -522,7 +511,7 @@
b_path = #{bPath,jdbcType=VARCHAR},
b_qualifier = #{bQualifier,jdbcType=VARCHAR}
where
- uuid = #{uuid}
+ uuid = #{uuid,jdbcType=VARCHAR}
</update>
<update id="updateBEnabledToFalse" parameterType="org.sonar.db.component.ComponentUpdateDto" useGeneratedKeys="false">
@@ -540,7 +529,7 @@
b_path = path,
b_qualifier = qualifier
where
- uuid in <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">#{uuid}</foreach>
+ uuid in <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">#{uuid,jdbcType=VARCHAR}</foreach>
</update>
@@ -569,7 +558,7 @@
b_path = null,
b_qualifier = null
where
- project_uuid = #{projectUuid} and
+ project_uuid = #{projectUuid,jdbcType=VARCHAR} and
b_changed = ${_true}
</update>
@@ -577,12 +566,12 @@
update projects
set b_changed = ${_false}
where
- project_uuid = #{projectUuid} and
+ project_uuid = #{projectUuid,jdbcType=VARCHAR} and
b_changed = ${_true}
</update>
<delete id="delete" parameterType="long">
- DELETE FROM projects WHERE id=#{id}
+ DELETE FROM projects WHERE id=#{id,jdbcType=BIGINT}
</delete>
</mapper>
diff --git a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
index 102c9497a51..1a2fa61ff2e 100644
--- a/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/component/SnapshotMapper.xml
@@ -38,9 +38,7 @@
SELECT
<include refid="snapshotColumns" />
FROM snapshots s
- <where>
- AND s.id=#{key}
- </where>
+ where s.id=#{key,jdbcType=BIGINT}
</select>
<select id="selectByIds" parameterType="Long" resultType="Snapshot">
@@ -51,7 +49,7 @@
WHERE
s.id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
- #{id}
+ #{id,jdbcType=BIGINT}
</foreach>
</select>
@@ -63,7 +61,7 @@
WHERE
s.uuid in
<foreach collection="uuids" item="uuid" separator="," open="(" close=")">
- #{uuid}
+ #{uuid,jdbcType=VARCHAR}
</foreach>
</select>
@@ -73,13 +71,13 @@
inner join projects p on s.component_uuid = p.project_uuid
where
s.islast=${_true}
- and p.uuid = #{componentUuid}
+ and p.uuid = #{componentUuid,jdbcType=VARCHAR}
</select>
<select id="selectLastSnapshotByRootComponentUuid" resultType="Snapshot">
select <include refid="snapshotColumns" />
from snapshots s
- where s.islast=${_true} and s.component_uuid = #{componentUuid}
+ where s.islast=${_true} and s.component_uuid = #{componentUuid,jdbcType=VARCHAR}
</select>
<select id="selectLastSnapshotsByRootComponentUuids" resultType="Snapshot">
@@ -89,7 +87,7 @@
s.islast=${_true}
and s.component_uuid in
<foreach collection="componentUuids" item="componentUuid" separator="," open="(" close=")">
- #{componentUuid}
+ #{componentUuid,jdbcType=VARCHAR}
</foreach>
</select>
@@ -98,23 +96,23 @@
<include refid="snapshotColumns" />
FROM snapshots s
<if test="query.componentUuid != null">
- INNER JOIN projects p ON p.uuid=s.component_uuid AND p.enabled=${_true} AND s.component_uuid=#{query.componentUuid}
+ INNER JOIN projects p ON p.uuid=s.component_uuid AND p.enabled=${_true} AND s.component_uuid=#{query.componentUuid,jdbcType=VARCHAR}
</if>
<where>
<if test="query.status != null">
- AND s.status=#{query.status}
+ AND s.status=#{query.status,jdbcType=VARCHAR}
</if>
<if test="query.version != null">
- AND s.version=#{query.version}
+ AND s.version=#{query.version,jdbcType=VARCHAR}
</if>
<if test="query.isLast != null">
AND s.islast=#{query.isLast}
</if>
<if test="query.createdAfter != null">
- AND s.created_at>=#{query.createdAfter}
+ AND s.created_at>=#{query.createdAfter,jdbcType=BIGINT}
</if>
<if test="query.createdBefore != null">
- AND s.created_at&lt;#{query.createdBefore}
+ AND s.created_at&lt;#{query.createdBefore,jdbcType=BIGINT}
</if>
</where>
<if test="query.sortField != null">
@@ -137,7 +135,7 @@
FROM snapshots s
INNER JOIN events e ON s.uuid = e.analysis_uuid AND e.name &lt;&gt; #{lastVersion} AND e.category='Version'
<where>
- s.component_uuid=#{componentUuid}
+ s.component_uuid=#{componentUuid,jdbcType=VARCHAR}
</where>
ORDER BY e.event_date DESC
</select>
@@ -147,7 +145,7 @@
<include refid="snapshotColumns" />
FROM snapshots s
<where>
- s.component_uuid=#{componentUuid}
+ s.component_uuid=#{componentUuid,jdbcType=VARCHAR}
</where>
ORDER BY s.created_at ASC
</select>
@@ -157,9 +155,9 @@
<include refid="viewsSnapshotColumns" />
FROM snapshots s
<where>
- and s.component_uuid = #{componentUuid}
+ and s.component_uuid = #{componentUuid,jdbcType=VARCHAR}
and s.status = 'P'
- and s.created_at &lt; #{date}
+ and s.created_at &lt; #{date,jdbcType=BIGINT}
</where>
order by created_at desc
</select>
@@ -167,21 +165,21 @@
<update id="unsetIsLastFlagForComponentUuid" parameterType="map">
update snapshots
set islast = ${_false}
- where component_uuid = #{componentUuid}
+ where component_uuid = #{componentUuid,jdbcType=VARCHAR}
and islast = ${_true}
</update>
<update id="setIsLastFlagForAnalysisUuid" parameterType="map">
update snapshots
set islast = ${_true}, status = 'P'
- where uuid = #{analysisUuid}
+ where uuid = #{analysisUuid,jdbcType=VARCHAR}
</update>
<update id="update" parameterType="Snapshot">
update snapshots
set version = #{version, jdbcType=VARCHAR},
status = #{status, jdbcType=VARCHAR}
- where uuid = #{uuid}
+ where uuid = #{uuid,jdbcType=VARCHAR}
</update>
<insert id="insert" parameterType="Snapshot" keyColumn="id" useGeneratedKeys="true" keyProperty="id">