mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
68189: Merged PLATFORM1 (4.3/Cloud) to HEAD-BUG-FIX (4.3/Cloud) 63165: ACE-482: sinceTxId clause in SQL query is no longer generated unless sinceTxId is non-null git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@68454 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
122 lines
6.6 KiB
XML
122 lines
6.6 KiB
XML
<?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="alfresco.metadata.query">
|
|
|
|
<sql id="sql_select_byDynamicQuery">
|
|
select
|
|
node.id as id
|
|
from
|
|
alf_node node
|
|
<foreach item="item" index="index" collection="joins">
|
|
<choose>
|
|
<when test="item.type == 'PARENT'">
|
|
<if test="item.outer">left outer </if>join alf_child_assoc ${item.alias} on (${item.alias}.child_node_id = node.id)
|
|
</when>
|
|
<when test="item.type == 'PROPERTY'">
|
|
<if test="item.outer">left outer </if>join alf_node_properties ${item.alias} on ((${item.alias}.node_id = node.id) AND (#{item.qnameId} = ${item.alias}.qname_id))
|
|
</when>
|
|
<when test="item.type == 'CONTENT_MIMETYPE'">
|
|
<if test="item.outer">left outer </if>join alf_node_properties ${item.alias}_p on ((${item.alias}_p.node_id = node.id) AND (#{item.qnameId} = ${item.alias}_p.qname_id))
|
|
<if test="item.outer">left outer </if>join alf_content_data ${item.alias}_cd on (${item.alias}_cd.id = ${item.alias}_p.long_value)
|
|
<if test="item.outer">left outer </if>join alf_mimetype ${item.alias} on (${item.alias}_cd.content_mimetype_id = ${item.alias}.id)
|
|
</when>
|
|
<when test="item.type == 'CONTENT_URL'">
|
|
<if test="item.outer">left outer </if>join alf_node_properties ${item.alias}_p on ((${item.alias}_p.node_id = node.id) AND (#{item.qnameId} = ${item.alias}_p.qname_id))
|
|
<if test="item.outer">left outer </if>join alf_content_data ${item.alias}_cd on (${item.alias}_cd.id = ${item.alias}_p.long_value)
|
|
<if test="item.outer">left outer </if>join alf_content_url ${item.alias} on (${item.alias}.id = ${item.alias}_cd.content_url_id)
|
|
</when>
|
|
<when test="item.type == 'ASPECT'">
|
|
<if test="item.outer">left outer </if>join alf_node_aspects ${item.alias} on (${item.alias}.node_id = node.id)
|
|
</when>
|
|
</choose>
|
|
</foreach>
|
|
where
|
|
node.type_qname_id <> #{sysDeletedType}
|
|
AND node.store_id = #{storeId}
|
|
<if test="sinceTxId != null">
|
|
AND node.transaction_id > #{sinceTxId}
|
|
</if>
|
|
<if test="hasPredicate">
|
|
AND
|
|
<foreach item="item" index="index" collection="predicateParts">
|
|
<choose>
|
|
<when test="item.type == 'OPEN'">
|
|
(
|
|
</when>
|
|
<when test="item.type == 'CLOSE'">
|
|
)
|
|
</when>
|
|
<when test="item.type == 'AND'">
|
|
AND
|
|
</when>
|
|
<when test="item.type == 'OR'">
|
|
OR
|
|
</when>
|
|
<when test="item.type == 'NOT'">
|
|
NOT
|
|
</when>
|
|
<when test="item.type == 'NP_MATCHES'">
|
|
1 = 1
|
|
</when>
|
|
<when test="item.type == 'NP_FAILS'">
|
|
1 = 0
|
|
</when>
|
|
<when test="item.type == 'EQUALS'">
|
|
${item.fieldAndFunction} = #{item.value}
|
|
</when>
|
|
<when test="item.type == 'EXISTS'">
|
|
${item.alias}.${item.fieldName} IS NOT NULL
|
|
</when>
|
|
<when test="item.type == 'NOTEXISTS'">
|
|
${item.alias}.${item.fieldName} IS NULL
|
|
</when>
|
|
<when test="item.type == 'GT'">
|
|
${item.fieldAndFunction} > #{item.value}
|
|
</when>
|
|
<when test="item.type == 'GTE'">
|
|
${item.fieldAndFunction} >= #{item.value}
|
|
</when>
|
|
<when test="item.type == 'LT'">
|
|
${item.fieldAndFunction} < #{item.value}
|
|
</when>
|
|
<when test="item.type == 'LTE'">
|
|
${item.fieldAndFunction} <= #{item.value}
|
|
</when>
|
|
<when test="item.type == 'IN'">
|
|
${item.fieldAndFunction} IN <foreach item="val" index="iVal" collection="item.values" open="(" separator="," close=")">#{val}</foreach>
|
|
</when>
|
|
<when test="item.type == 'NOTIN'">
|
|
${item.fieldAndFunction} NOT IN <foreach item="val" index="iVal" collection="item.values" open="(" separator="," close=")">#{val}</foreach>
|
|
</when>
|
|
<when test="item.type == 'LIKE'">
|
|
${item.fieldAndFunction} LIKE #{item.value} <include refid="alfresco.util.escape"/>
|
|
</when>
|
|
<when test="item.type == 'NOTLIKE'">
|
|
${item.fieldAndFunction} NOT LIKE #{item.value} <include refid="alfresco.util.escape"/>
|
|
</when>
|
|
<when test="item.type == 'NOTEQUALS'">
|
|
${item.fieldAndFunction} <> #{item.value}
|
|
</when>
|
|
<when test="item.type == 'ASPECT'">
|
|
${item.alias}.qname_id IN <foreach item="val" index="iVal" collection="item.values" open="(" separator="," close=")">#{val}</foreach>
|
|
</when>
|
|
<!-- skip ORDER and NO_ORDER -->
|
|
</choose>
|
|
</foreach>
|
|
</if>
|
|
<if test="hasOrderBy">
|
|
order by
|
|
<foreach item="item" index="index" collection="predicateParts" open="" separator="," close="">
|
|
<choose>
|
|
<!-- Only look at ORDER items -->
|
|
<when test="item.type == 'ORDER'">
|
|
${item.alias}.${item.fieldName} ${item.value}
|
|
</when>
|
|
</choose>
|
|
</foreach>
|
|
</if>
|
|
</sql>
|
|
|
|
</mapper> |