iam串联字符串和表达式中的case语句中的条件在满足下面提到的代码时。
。CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<Object[]> cq = builder.createQuery(Object[].class);
Root<StudentRegistration> root = cq.from(StudentRegistration.class);
Expression<Object> str = builder.selectCase().when(builder.greaterThanOrEqualTo(root.get(StudentRegistration_.studentRegistrationGrade), 3),builder.concat("CDATA",root.get(StudentRegistration_.studentRegistrationGrade))).otherwise("-1");
cq.select(str);
em.createQuery(cq).getResultList();
由于编写cont函数在案例语句中IAM的函数以下。我通过给builder.literal()尝试了所有可能的方法,但是我无法解决此问题。自两天以来,我就一直遇到了这个问题。请帮助我。
java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: || near line 1, column 314 [select case when generatedAlias0.studentRegistrationGrade >=3 then :param0 || generatedAlias0.studentRegistrationGrade else :param1 end from StudentRegistration as generatedAlias0]
at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750)
预先感谢
您是否为DB设置了适当的方言?