我在Spring Boot项目中使用了以下查询,但它运行良好。
@Query ("SELECT b.belgeKok FROM BelgeEntity b WHERE (b.evrakTurId = ?1 OR ?1 = 0) AND (b.firmaId = ?2 OR ?2 = 0) AND (b.kategoriId = ?3 OR ?3 = 0) "
+ "AND (b.belgeTurId = ?4 OR ?4 = 0) AND (b.projeId = ?5 OR ?5 = 0) AND (b.aciklama LIKE %?6% OR ?6 = '') AND (b.ocr LIKE %?7% OR ?7 = '')")
public List<String> findByCustomQuery(Integer et, Integer firma, Integer kategori, Integer belgeTur, Integer proje, String aciklama, String kelime1);
现在我需要为一列搜索多个单词,并且需要使用Postgres LIKE ALL查询并将数组列表作为参数。
首先有一种方法可以在@Query注释中使用LIKE ALL查询吗? 我用谷歌搜索,但可以找到任何东西。
当我尝试以下查询时,它会出现语法错误,如下所示
@Query (value="SELECT b.belgeKok FROM BelgeEntity b WHERE (b.evrakTurId = ?1 OR ?1 = 0) AND (b.firmaId = ?2 OR ?2 = 0) AND (b.kategoriId = ?3 OR ?3 = 0) "
+ "AND (b.belgeTurId = ?4 OR ?4 = 0) AND (b.projeId = ?5 OR ?5 = 0) AND (b.aciklama LIKE %?6% OR ?6 = '') AND (b.ocr LIKE ALL ?7 OR ?7 = '')", nativeQuery = true)
public List<String> findByCustomQuery(Integer et, Integer firma, Integer kategori, Integer belgeTur, Integer proje, String aciklama, Set<String> kelime1);
15:51:25.790 [http-nio-8888-exec-7]警告o.h.e.jdbc.spi.SqlExceptionHelper - SQL错误:0,SQLState:42601 15:51:25.790 [http-nio-8888-exec-7]错误o.h.e.jdbc.spi.SqlExceptionHelper - 错误:语法错误在或附近&#34;,&#34; 职位:267 15:51:25.805 [http-nio-8888-exec-7]错误oaccC [。[。[。[dispatcherServlet] - servlet [dispatcherServlet]的Servlet.service()在上下文中,路径[]引发异常[请求处理失败;嵌套异常是org.springframework.dao.InvalidDataAccessResourceUsageException:无法提取ResultSet; SQL [不适用];嵌套异常是org.hibernate.exception.SQLGrammarException:无法提取ResultSet]的根本原因 org.postgresql.util.PSQLException:错误:语法错误在或附近&#34;,&#34; 职位:267
当我尝试这样做时:( b.ocr LIKE ALL&#39;?7&#39; OR?7 =&#39;&#39;) 它会在&#34;(#:x7_0 _,:x7_1 _)&#39;&#39;&#39;&#39;
之前或附近出现语法错误非常感谢提前! 穆拉特