简体   繁体   English

带有Likes的Hibernate HQL意外令牌

[英]Hibernate HQL unexpected token with Likes

I have this class in my Spring Web model-view-controller (MVC) framework. 我的Spring Web模型-视图-控制器(MVC)框架中有此类。 The version of the Spring Web model-view-controller (MVC) framework is 3.2.8. Spring Web模型-视图-控制器(MVC)框架的版本为3.2.8。

and I have this method in 1 DAO 我在1 DAO中有这种方法

final StringBuilder queryString = new StringBuilder("  select app from Application app where upper (ticket_id) like :searchString and upper (id) like :searchString " );

        queryString.append("where  app.status != " + Status.READY.ordinal());

        queryString.append(" order by app.submissionTime desc ");

        try {

            final Query query = getEntityManager().createQuery(queryString.toString());

            searchString = searchString.replace("!", "!!")
                       .replace("%", "!%")
                       .replace("_", "!_")
                       .replace("[", "![")
                       .trim()
                       .toUpperCase();


            query.setParameter ("searchString", searchString);                      

            return query.getResultList();

But I have this error on runtime: 但是我在运行时遇到这个错误:

 org.   where near line 1, column 144 [  select app from com.tdk.devices.domain.Application app where upper (ticket_id) like :searchString and upper (id) like :searchString where  app.status != 0 order by app.submissionTime desc ]

You used "where" clause 2 times. 您使用了“ where”子句两次。 First in the constructor of StringBuilder, then: 首先在StringBuilder的构造函数中,然后:

queryString.append("where  app.status != " + Status.READY.ordinal());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM