return findByDataspaceIdAndXpathIn(dataspaceEntity.getId(), xpaths.toArray(new String[0]));\r
}\r
\r
+ @Query(value = "SELECT * FROM fragment WHERE anchor_id IN (:anchorIds)"\r
+ + " AND xpath = ANY (:xpaths)", nativeQuery = true)\r
+ List<FragmentEntity> findByAnchorIdsAndXpathIn(@Param("anchorIds") Long[] anchorIds,\r
+ @Param("xpaths") String[] xpaths);\r
+\r
@Query(value = "SELECT * FROM fragment WHERE anchor_id = :anchorId LIMIT 1", nativeQuery = true)\r
Optional<FragmentEntity> findOneByAnchorId(@Param("anchorId") long anchorId);\r
\r
return findAllXpathByAnchorIdAndXpathIn(anchorEntity.getId(), xpaths.toArray(new String[0]));\r
}\r
\r
- boolean existsByAnchorAndXpathStartsWith(AnchorEntity anchorEntity, String xpath);\r
+ @Query(value = "SELECT EXISTS(SELECT 1 FROM fragment WHERE anchor_id = :anchorId"\r
+ + " AND xpath LIKE :xpathPattern LIMIT 1)", nativeQuery = true)\r
+ boolean existsByAnchorIdAndParentXpathAndXpathLike(@Param("anchorId") long anchorId,\r
+ @Param("xpathPattern") String xpathPattern);\r
+\r
+ default boolean existsByAnchorAndXpathStartsWith(final AnchorEntity anchorEntity, final String xpath) {\r
+ return existsByAnchorIdAndParentXpathAndXpathLike(anchorEntity.getId(),\r
+ EscapeUtils.escapeForSqlLike(xpath) + "%");\r
+ }\r
\r
@Query(value = "SELECT * FROM fragment WHERE anchor_id = :anchorId AND parent_id IS NULL", nativeQuery = true)\r
List<FragmentEntity> findRootsByAnchorId(@Param("anchorId") long anchorId);\r