Java Spring JPA-意外的AST节点

Java Spring JPA-意外的AST节点,java,hibernate,spring-data-jpa,hql,jpql,Java,Hibernate,Spring Data Jpa,Hql,Jpql,我开始了一个学习SpringDataJPA的项目。此查询用于检索与数据库中的配置文件关联的所有合同 要求是搜索条件需要是动态的:可以是空的、空的或值,这一行是构建这样一个语句的示例: (?1为null或?1=''或(p.fullname如%?1%和c.borrowerId=p.id)) 但在执行时,我遇到了一个错误:,原因是:org.hibernate.hql.internal.ast.QuerySyntaxException:unexpected ast node 这就是我试图执行的查询,有人

我开始了一个学习SpringDataJPA的项目。此查询用于检索与数据库中的配置文件关联的所有
合同

要求是搜索条件需要是动态的:可以是空的、空的或值,这一行是构建这样一个语句的示例:

(?1为null或?1=''或(p.fullname如%?1%和c.borrowerId=p.id))

但在执行时,我遇到了一个错误:
,原因是:org.hibernate.hql.internal.ast.QuerySyntaxException:unexpected ast node

这就是我试图执行的查询,有人能解释一下为什么代码会出现上面的错误吗?如果我设置了
nativeQuery=true
,则查询可以成功执行,但如果我尝试使用HQL语法,则会出现错误

以下是查询:

@Query(value = "select c from Contract c, Profile p where \n" +
"(?1 is null or ?1 = '' or (p.fullname like %?1% and c.borrowerId = p.id)) and \n" +
"(?2 is null or ?2 = '' or (p.phone like (select phone where p.phone like %?2% and p.id = c.borrowerId group by p.phone))) \n" +
"and (?3 is null or ?3 = '' or c.createdDate >= ?3) and (?4 is null or ?4 = '' or c.createdDate <= ?4) " + "and (?5 is null or ?5 = '' or c.status = ?5) ")
Page<Contract> findContractsWithOptionalParameters(String name, String phone, Date startDate, Date endDate, String status, Pageable pageable);
@Query(value=“从合同c、配置文件p中选择c,其中\n”+
(?1为null或?1=''或(p.fullname如%?1%和c.borrowerId=p.id))和\n+
“(?2为空或?2=''或(p.phone-like(选择phone,其中p.phone-like%?2%和p.id=c.borrowerId-group by p.phone))\n”+

和(?3为null或?3=''或c.createdDate>=?3)和(?4为null或?4=''或c.createdDate请看关于这个问题的第二个答案:-它可能比您的答案更容易阅读:-)。请发布完整的堆栈跟踪。我已尝试重写查询,以避免嵌套的select子句。它正在按预期工作。我将结束此问题。