我正在尝试使用带有查询的命名 JDBC 模板运行类似的匹配...
SELECT
id, guid, body, summary, status_id, language_id, is_mce, content_type_id,
last_edited_by, locked_by, owner_id, coordinator_id, writer_id, paperless,
content_body_type, created, updated, locked_timestamp
FROM dbo.content
WHERE notes LIKE :notes
:notes
是必然的%test%
,不幸的是它没有返回任何结果。我检查了数据库并验证了该数据是否存在。这不是执行类似匹配的正确方法吗?
更新
生成此查询的部分代码...
String notes = search.getNotes();
if (notes instanceof String && notes.length() > 0) {
if (!previousClause) {
searchQuery.append("WHERE ");
previousClause = true;
}
searchQuery.append("notes LIKE :notes AND ");
queryMap.put("notes", "%"+notes+"%");
}
Collection<Category> categories = search.getCategoryCollection();
if (categories != null && categories.size() > 0) {
Short x = 0;
for (Category category : categories) {
searchQuery.append("INNER JOIN dbo.content_to_category AS content_to_category"+x.toString()+" ON (content_to_category"+x.toString()+".category_id IN (:categoryId"+x.toString()+") AND content_to_category"+x.toString()+".content_id = content.id) ");
queryMap.put("categoryId"+x.toString(), category.getId());
x++;
}
}