【发布时间】:2021-09-13 12:28:10
【问题描述】:
我正在按姓名、姓氏和数字进行过滤。有时我想按单个姓名搜索,有时按姓名和姓氏搜索,有时按 all.LIKE 和 is null 操作不起作用。
例子
姓名:亚当姓氏:最大编号:1235464 工作
姓名:亚当姓氏:最大编号:(空)不工作
2021-09-13 15:45:48 ERROR o.a.c.c.C.[.[.[.[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
oracle.jdbc.OracleDatabaseException: ORA-01722: invalid number
@Transactional
@Modifying
@Query(value = "SELECT U.* FROM USER U "
+ "LEFT JOIN CV ON U.USERID=CV.USERID "
+ "JOIN PROFIL P ON P.CV_ID=CV.CV_ID "
+ "AND(:name is null OR P.name LIKE %:name% ) "
+ "AND (:surname is null OR P.surname LIKE %:surname% ) "
+ "AND (:no is null OR U.no=:no ) ", nativeQuery = true)
public List<User> findByDynamicQuery(@Param("name") String name, @Param("surname") String surname, @Param("no") String no);
【问题讨论】:
-
我们肯定需要更多详细信息才能为您提供帮助。
-
你能发布你的用户模型类的代码吗?
标签: sql spring-boot jpa