org.hibernate.hql.internal.ast.QuerySyntaxException:意外令牌:> =第1行附近

时间:2015-05-02 23:54:19

标签: java mysql database hibernate exception

当我用Hibernate运行这个查询时,我得到了一个例外:

String query = "FROM A st, B g "
                + "WHERE st.name = g.name AND st.name LIKE :name AND "
                + "g.id = ANY (SELECT c FROM C "
                + "WHERE CASE WHEN name = 'test' THEN condiction >= :value end)";

        try {
            return (List) entityManager.createQuery(query)
                    .setParameter("name", "%" + name + "%")
                    .setParameter("value", value).getResultList();
        } catch (SecurityException | IllegalStateException | RollbackException e) {
            LOGGER.info(e.getMessage());
        }
        return null;

我得到了一个箴言:

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: >= near line 1, column 336 ...
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1750)
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1677)
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1683)
    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:331)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

有关它的任何想法?我使用mysql数据库。我可以在休眠时使用CASE吗?相同的查询在命令行上正常工作。

感谢 干杯

0 个答案:

没有答案