<select id="findById" resultType="foo">
SELECT *
FROM foo_table
WHERE id = #{id}
limit 1
</select>
<select id="findByStauts" resultType="foo">
SELECT *
FROM foo_table
WHERE status = #{status}
limit 1
</select>
字符串
我想确保条件'limit 1'在所有查询中。
有没有办法在Spring Test中进行检查?
1条答案
按热度按时间mftmpeh81#
您可以使用xPath遍历这些XML标记,并检查
limit 1
是否在其值内:1.导入库并初始化对象:
字符串
1.将文件转换为字符串。有很多方法可以做到这一点。点击此处查看:https://mkyong.com/java/java-convert-file-to-string/的数据。
1.现在,我们将遍历所有的
select
标签,并检查它们是否包含limit 1
。假设步骤2中的字符串名为“myXML”:型
在这个代码块
xPath.evaluate(xpathSelectTag+"["+i+"]"
中,我们取i
索引所在的select
标签的值。所以,我们遍历所有这些。请评论任何问题,以便我可以帮助你。