<i id='eftUB'><tr id='eftUB'><dt id='eftUB'><q id='eftUB'><span id='eftUB'><b id='eftUB'><form id='eftUB'><ins id='eftUB'></ins><ul id='eftUB'></ul><sub id='eftUB'></sub></form><legend id='eftUB'></legend><bdo id='eftUB'><pre id='eftUB'><center id='eftUB'></center></pre></bdo></b><th id='eftUB'></th></span></q></dt></tr></i><div id='eftUB'><tfoot id='eftUB'></tfoot><dl id='eftUB'><fieldset id='eftUB'></fieldset></dl></div>

    1. <small id='eftUB'></small><noframes id='eftUB'>

      <legend id='eftUB'><style id='eftUB'><dir id='eftUB'><q id='eftUB'></q></dir></style></legend>
      <tfoot id='eftUB'></tfoot>
        <bdo id='eftUB'></bdo><ul id='eftUB'></ul>
      1. spring jpa @Query 错误,期待 CLOSE,发现 '(' 附近

        时间:2024-08-24

        <legend id='4xQNT'><style id='4xQNT'><dir id='4xQNT'><q id='4xQNT'></q></dir></style></legend>
          <bdo id='4xQNT'></bdo><ul id='4xQNT'></ul>

          <small id='4xQNT'></small><noframes id='4xQNT'>

              <tbody id='4xQNT'></tbody>
            • <i id='4xQNT'><tr id='4xQNT'><dt id='4xQNT'><q id='4xQNT'><span id='4xQNT'><b id='4xQNT'><form id='4xQNT'><ins id='4xQNT'></ins><ul id='4xQNT'></ul><sub id='4xQNT'></sub></form><legend id='4xQNT'></legend><bdo id='4xQNT'><pre id='4xQNT'><center id='4xQNT'></center></pre></bdo></b><th id='4xQNT'></th></span></q></dt></tr></i><div id='4xQNT'><tfoot id='4xQNT'></tfoot><dl id='4xQNT'><fieldset id='4xQNT'></fieldset></dl></div>

              <tfoot id='4xQNT'></tfoot>
                  本文介绍了spring jpa @Query 错误,期待 CLOSE,发现 '(' 附近的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有以下 JPQL:

                  @Query("SELECT su.id, su.nameCn, count(b.id), avg(s.rate), count(concat(b.id, '@', s.user.id)) "
                              + "FROM S su, B b, S s where b.st.id = su.id and s.bd.id = b.id and su.mt.id = ?1 group by su.id")
                  

                  当我添加 concat(b.id, '@', s.user.id) 时,它会显示:

                  When I add concat(b.id, '@', s.user.id), it shows me:

                  org.hibernate.hql.internal.ast.QuerySyntaxException: 期待 CLOSE,在第 1 行附近找到 '(',在 org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:115) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:76) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final]在 org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291) ~[hibernate-entitymanager-5.1.0.Final.jar:5.1.0.Final]

                  org.hibernate.hql.internal.ast.QuerySyntaxException: expecting CLOSE, found '(' near line 1, at org.hibernate.hql.internal.ast.QuerySyntaxException.convert(QuerySyntaxException.java:74) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.ErrorCounter.throwQueryException(ErrorCounter.java:91) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:288) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:187) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:142) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:115) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.HQLQueryPlan.(HQLQueryPlan.java:76) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:150) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:302) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:240) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.internal.SessionImpl.createQuery(SessionImpl.java:1907) ~[hibernate-core-5.1.0.Final.jar:5.1.0.Final] at org.hibernate.jpa.spi.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:291) ~[hibernate-entitymanager-5.1.0.Final.jar:5.1.0.Final]

                  推荐答案

                  期待关闭,发现 (

                  这里的术语 CLOSE 指的是右括号,).

                  The term CLOSE here refers to a closing bracket, ).

                  查询解析器似乎不支持在 count(...) 中调用另一个函数.

                  It would appear that the query parser does not support calling another function inside the count(...).

                  也就是说语法错误在这里:

                  In other words, the syntax error is here:

                  SELECT su.id, su.nameCn, count(b.id), avg(s.rate), count(concat(b.id, '@', s.user.id))
                                                                                 ^
                  

                  也许您的意思是进行某种联接,并计算那里的行数?

                  Perhaps you mean to be doing some kind of join, and counting the rows there?

                  这篇关于spring jpa @Query 错误,期待 CLOSE,发现 '(' 附近的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:列名作为 Spring Data JPA Query 的参数 下一篇:具有多个 in 运算符的 crudrepository findBy 方法签名?

                  相关文章

                    <bdo id='OqZ7S'></bdo><ul id='OqZ7S'></ul>
                  <tfoot id='OqZ7S'></tfoot>
                  1. <legend id='OqZ7S'><style id='OqZ7S'><dir id='OqZ7S'><q id='OqZ7S'></q></dir></style></legend>
                  2. <small id='OqZ7S'></small><noframes id='OqZ7S'>

                  3. <i id='OqZ7S'><tr id='OqZ7S'><dt id='OqZ7S'><q id='OqZ7S'><span id='OqZ7S'><b id='OqZ7S'><form id='OqZ7S'><ins id='OqZ7S'></ins><ul id='OqZ7S'></ul><sub id='OqZ7S'></sub></form><legend id='OqZ7S'></legend><bdo id='OqZ7S'><pre id='OqZ7S'><center id='OqZ7S'></center></pre></bdo></b><th id='OqZ7S'></th></span></q></dt></tr></i><div id='OqZ7S'><tfoot id='OqZ7S'></tfoot><dl id='OqZ7S'><fieldset id='OqZ7S'></fieldset></dl></div>