简体   繁体   English

如何让@Query 在 JPA 中执行 ContainingIgnoreCase 函数?

[英]How to make @Query perform ContainingIgnoreCase function in JPA?

I have made a @Query in JPA that returns the all values of a table that are related to a table according to its name but I would like it to work as a ContainingIgnoreCase, I have tried LIKE but it gives me an error.我在 JPA 中创建了一个 @Query,它根据名称返回与表相关的表的所有值,但我希望它作为 ContainingIgnoreCase 工作,我尝试过 LIKE,但它给了我一个错误。

@Query("select v from Variedad v "
            + "join v.especie e "
            + "where v.dtype='Variedad' "
            + "and e.nombre = :nombreEspecie "
//          + "like %?1%"
            + "order by v.nombre asc")
Page<Variedad> listarTodosFiltradoPorNombreEspecie(String nombreEspecie, Pageable pagina);

Have you tried to add IgnoreCase at the end of the method, so JPA will do the job for you (as per https://docs.spring.io/spring-data/jpa/docs/1.5.1.RELEASE/reference/html/jpa.repositories.html#jpa.query-methods.query-creation )?您是否尝试在方法末尾添加 IgnoreCase,因此 JPA 将为您完成这项工作(根据https://docs.spring.io/spring-data/jpa/docs/1.5.1.RELEASE/reference/ html/jpa.repositories.html#jpa.query-methods.query-creation )? Also, you can try to modify your SQL as such "... UPPER(e.nombre) = UPPER(:nombreEspecie) ...".此外,您可以尝试将 SQL 修改为“... UPPER(e.nombre) = UPPER(:nombreEspecie) ...”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM