使用jpa查询搜索短语字符串

时间:2017-05-30 19:23:06

标签: spring-data

我使用Spring Data搜索JPA查询,如下所示:

我的界面存储库:

public interface AnnonceDao extends   JpaRepository<Annonce, Integer> {
    Page<Annonce> findByTitreContaining(String titre,Pageable page);
}

当我寻找像 Hello Friend 这样的东西时,我得到了所有让Hello Friend连接的实体,我想要得到的东西 Friend Hello 或任何包含您好或朋友。我可以使用什么作为查询,感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

这应该有效:

#Variables to use with model
graph = tf.get_default_graph()
x = graph.get_tensor_by_name("x:0")
y_ = graph.get_tensor_by_name("y_:0")
keep_prob = graph.get_tensor_by_name("keep_prob:0")#Changed this
accuracy = graph.get_tensor_by_name("accuracy:0")

如果您想要传递的术语数量在编译时未知,正如您在评论中解释的那样,您可以使用Specifications

这使得向存储库的客户端创建规范的任务。如果您不喜欢,可以提供自定义方法并在其中动态创建查询。您可以选择多种技术:

  • SQL
  • JQL
  • QueryDsl

QueryDsl looks actually really nice并且可以在linke示例中看到。