SampleRepository.java类具有如下查询:
@Query("select eq from EmailQueue eq where eq.inquiry in (select issue.id from Inquiry issue where issue.id = eq.inquiry and systimestamp >= eq.sendDate + (1/24) * ?3 ) and "
+ " systimestamp >= eq.sendDate + (1/24) * ?2 and eq.sent = True and "
+ " eq.emailType.id = ?1 "
+ " order by eq.sendDate asc")
我得到的错误是:
Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "TRUE": invalid identifier
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:450) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:399) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:1059) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:522) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:257) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:587) ~[ojdbc7-12.1.0.2.jar:12.1.0.2.0]
您能让我知道如何在@query中指定 eq.sent = True 吗?我试过了 eq.sent = 1也不能正常工作。
答案 0 :(得分:0)
您可以使用is
代替=
:
@Query("select eq from EmailQueue eq where eq.inquiry in (select issue.id from Inquiry issue where issue.id = eq.inquiry and systimestamp >= eq.sendDate + (1/24) * ?3 ) and "
+ " systimestamp >= eq.sendDate + (1/24) * ?2 and eq.sent is True and "
+ " eq.emailType.id = ?1 "
+ " order by eq.sendDate asc")
答案 1 :(得分:0)
通过以下解决方法解决:
@Query("select eq from EmailQueue eq where eq.inquiry in (select issue.id from Inquiry issue where issue.id = eq.inquiry and systimestamp >= eq.sendDate + (1/24) * ?3 ) and "
+ " systimestamp >= eq.sendDate + (1/24) * ?2 and eq.sent = ?4 and "
+ " eq.emailType.id = ?1 "
+ " order by eq.sendDate asc")
List<EQueue> findEmailSentDetails(long type, int days1, int days2,boolean emailSent);
而不是使用“ eq.sent = true”,而是将true用作参数,例如 eq.sent =?4