I need help with this error: java.lang.NoSuchMethodError

I have this Java code (JPA):

String queryString = "SELECT b , sum(v.votedPoints) as votedPoint " + " FROM Bookmarks b " + " LEFT OUTER JOIN Votes v " + " on (v.organizationId = b.organizationId) " + "WHERE b.userId = 101 " + "GROUP BY b.organizationId " + "ORDER BY votedPoint ascending "; EntityManager em = getEntityManager(); Query query = em.createQuery(queryString); query.setFirstResult(start); query.setMaxResults(numRecords); List results = query.getResultList(); 

I do not know what is wrong with my request, because it gives me this error:

  java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover (Lantlr / RecognitionException; Lantlr / collections / impl / BitSet;) V
         at org.hibernate.hql.antlr.HqlBaseParser.fromJoin (HqlBaseParser.java:1802)
         at org.hibernate.hql.antlr.HqlBaseParser.fromClause (HqlBaseParser.java:1420)
         at org.hibernate.hql.antlr.HqlBaseParser.selectFrom (HqlBaseParser.java:1130)
         at org.hibernate.hql.antlr.HqlBaseParser.queryRule (HqlBaseParser.java:702)
         at org.hibernate.hql.antlr.HqlBaseParser.selectStatement (HqlBaseParser.java:296)
         at org.hibernate.hql.antlr.HqlBaseParser.statement (HqlBaseParser.java:159)
         at org.hibernate.hql.ast.QueryTranslatorImpl.parse (QueryTranslatorImpl.java:271)
         at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile (QueryTranslatorImpl.java:180)
         at org.hibernate.hql.ast.QueryTranslatorImpl.compile (QueryTranslatorImpl.java:134)
         at org.hibernate.engine.query.HQLQueryPlan. (HQLQueryPlan.java:101)
         at org.hibernate.engine.query.HQLQueryPlan. (HQLQueryPlan.java:80)
         at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan (QueryPlanCache.java:94)
         at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan (AbstractSessionImpl.java:156)
         at org.hibernate.impl.AbstractSessionImpl.createQuery (AbstractSessionImpl.java:135)
         at org.hibernate.impl.SessionImpl.createQuery (SessionImpl.java:1650)

Thanks.

+4
source share
9 answers

You definitely have a problem with the version of the sleep mode and ANTLR bars that you are using. The recovery method was not present in the ANTLR Parser class until version 2.7.6? If you are using an earlier version of ANTLR, such as 2.7.2, you will see this problem.

Using maven can lead to a situation where you are dependent on Hibernate and its transitive dependencies, but something is "closer"; e.g. Struts; providers of a different, earlier version of ANTLR and that an earlier version will be allowed in your application.

If you can provide a version of the cans involved, we can help a little more. Once you have fixed the issue with jar versions, you should get a more open error message that shows what is wrong with your HQL expression.

+7
source

Blow in the dark - you are sure that you have a consistent set of cans - perhaps you need to get the antlr banner that comes with the sleep mode distribution that you use ...

+2
source

I found the problem: because this is a native query, the Java classes for these two tables must have some special attributes:
in class Bookmarks.java

 @OneToMany(mappedBy = "bookmarkId") private Collection votesCollection; 
and in class Votes.java
 @JoinColumn(name = "bookmark_id", referencedColumnName = "bookmark_id") @ManyToOne [private Bookmarks bookmarkId; 

and I also changed the job request

 tring queryString = "SELECT b, sum(v.votedPoints) " + "FROM Bookmarks b " + "LEFT OUTER JOIN b.votesCollection v " + "WHERE b.userId = 101 " + "GROUP BY b.organizationId " + "ORDER BY sum(v.votedPoints) asc "; 

thanks for the help

+2
source

Perhaps you have several double quotes that are missing or that should be doubled in your HQL.

The illustration is here .

Or you will skip some simple quotes as shown in the picture there

+1
source

The request seems invalid if it is not a formatting artifact.

I think you meant this:

Select b, ...

:

Select b.organizationId, ...

??

+1
source

I have a consistent set of cans because simple queries like this

  "SELECT b FROM table_name b WHERE b.userId = 102" 

work. I checked all the double quotes and everything is fine.

My database is mysql and I use jpa to connect to it. I do not know what causes the problem. Perhaps this type of connection, I do not know

0
source

Er, this is your query, trying to select b, which is an alias of the table, and this is not allowed, as far as I know.

0
source

I would suggest that there is something wrong with your request because the HqlBaseParser method cannot be found, called recover(RecognitionException, Bitset) . Perhaps this request does not work for some reason, and other simpler requests (and the NoSuchMethod exception is thrown when trying to recover from this error).

 java.lang.NoSuchMethodError: org.hibernate.hql.antlr.HqlBaseParser.recover(Lantlr/RecognitionException;Lantlr/collections/impl/BitSet;)V 
0
source

Your request is still not right. It may work with your / db driver, but it is not standard SQL. You must choose b.* Or b.organizationId .

0
source

All Articles