You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileSourceMapper.xml 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
  3. <mapper namespace="org.sonar.db.source.FileSourceMapper">
  4. <select id="selectByFileUuid" parameterType="map" resultType="org.sonar.db.source.FileSourceDto">
  5. select
  6. id,
  7. project_uuid as projectUuid,
  8. file_uuid as fileUuid,
  9. created_at as createdAt,
  10. updated_at as updatedAt,
  11. binary_data as binaryData,
  12. line_hashes as rawLineHashes,
  13. line_hashes_version as lineHashesVersion,
  14. line_count as lineCount,
  15. data_hash as dataHash,
  16. src_hash as srcHash,
  17. revision
  18. from
  19. file_sources
  20. where
  21. file_uuid = #{fileUuid,jdbcType=VARCHAR}
  22. and data_type = 'SOURCE'
  23. </select>
  24. <select id="selectHashesForProject" parameterType="map" resultType="org.sonar.db.source.FileSourceDto">
  25. select
  26. id,
  27. file_uuid as fileUuid,
  28. data_hash as dataHash,
  29. src_hash as srcHash,
  30. revision,
  31. updated_at as updatedAt
  32. from
  33. file_sources
  34. where
  35. project_uuid = #{projectUuid,jdbcType=VARCHAR}
  36. and data_type = 'SOURCE'
  37. </select>
  38. <select id="scrollLineHashes" parameterType="map" resultType="org.sonar.db.source.LineHashesWithUuidDto" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
  39. select
  40. p.uuid as uuid,
  41. p.path as path,
  42. fs.line_hashes as rawLineHashes
  43. from projects p
  44. inner join file_sources fs on
  45. fs.file_uuid = p.uuid
  46. and fs.data_type = 'SOURCE'
  47. where
  48. p.uuid in
  49. <foreach collection="fileUuids" item="fileUuid" open="(" close=")" separator=",">
  50. #{fileUuid,jdbcType=VARCHAR}
  51. </foreach>
  52. and p.path is not null
  53. </select>
  54. <select id="selectLineHashesVersion" parameterType="map" resultType="Integer">
  55. SELECT
  56. line_hashes_version
  57. FROM
  58. file_sources
  59. WHERE
  60. file_uuid = #{fileUuid,jdbcType=VARCHAR}
  61. and data_type = 'SOURCE'
  62. </select>
  63. <insert id="insert" parameterType="org.sonar.db.source.FileSourceDto" useGeneratedKeys="false">
  64. insert into file_sources
  65. (
  66. project_uuid,
  67. file_uuid,
  68. created_at,
  69. updated_at,
  70. binary_data,
  71. line_hashes,
  72. line_hashes_version,
  73. line_count,
  74. data_hash,
  75. src_hash,
  76. data_type,
  77. revision
  78. )
  79. values
  80. (
  81. #{projectUuid,jdbcType=VARCHAR},
  82. #{fileUuid,jdbcType=VARCHAR},
  83. #{createdAt,jdbcType=BIGINT},
  84. #{updatedAt,jdbcType=BIGINT},
  85. #{binaryData,jdbcType=BLOB},
  86. #{rawLineHashes,jdbcType=CLOB},
  87. #{lineHashesVersion,jdbcType=INTEGER},
  88. #{lineCount,jdbcType=INTEGER},
  89. #{dataHash,jdbcType=VARCHAR},
  90. #{srcHash,jdbcType=VARCHAR},
  91. 'SOURCE',
  92. #{revision,jdbcType=VARCHAR}
  93. )
  94. </insert>
  95. <update id="update" parameterType="org.sonar.db.source.FileSourceDto" useGeneratedKeys="false">
  96. update
  97. file_sources
  98. set
  99. updated_at = #{updatedAt,jdbcType=BIGINT},
  100. binary_data = #{binaryData,jdbcType=BLOB},
  101. line_hashes = #{rawLineHashes,jdbcType=CLOB},
  102. line_hashes_version = #{lineHashesVersion,jdbcType=INTEGER},
  103. line_count = #{lineCount,jdbcType=INTEGER},
  104. data_hash = #{dataHash,jdbcType=VARCHAR},
  105. src_hash = #{srcHash,jdbcType=VARCHAR},
  106. revision = #{revision,jdbcType=VARCHAR}
  107. where
  108. id = #{id,jdbcType=INTEGER}
  109. </update>
  110. </mapper>