Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Criteria API fails with EclipseLink JPA provider #8

Open
GoogleCodeExporter opened this issue Feb 26, 2016 · 0 comments
Open

Criteria API fails with EclipseLink JPA provider #8

GoogleCodeExporter opened this issue Feb 26, 2016 · 0 comments

Comments

@GoogleCodeExporter
Copy link

Given some Java code like:

  Criteria criteria = Criteria.forClass(Projet.class);
  criteria.add(Restrictions.eq("campagne.id", idCampagne));

  DAO.findByCriteria(criteria);

Using EclipseLink JPA provider (I updated the pom.xml), I get this error:

java.lang.IllegalArgumentException: An exception occurred while creating a 
query in EntityManager: 
Exception Description: Syntax error parsing the query [select this from Projet 
as this where this.campagne.id=?], line 0, column -1: unexpected end of query.
Internal Exception: NoViableAltException(-1!=[792:1: 
comparisonExpressionRightOperand returns [Object node] : (n= 
arithmeticExpression | n= nonArithmeticScalarExpression | n= anyOrAllExpression 
);])
    at org.eclipse.persistence.internal.jpa.EntityManagerImpl.createQuery(EntityManagerImpl.java:1373)
    at com.szczytowski.genericdao.criteria.Criteria.prepareQuery(Criteria.java:333)
    at com.szczytowski.genericdao.criteria.Criteria.list(Criteria.java:236)
    at com.szczytowski.genericdao.impl.GenericDao.findByCriteria(GenericDao.java:319)
[...]


It looks like "select this from Projet as this where this.campagne.id=?" is not 
a valid JPQL query.

AFAIK numbered parameters must be specified with an index, e.g.:
  "select this from Projet as this where this.campagne.id=?1"

Whereas Hibernate HQL doesn't need this index, that's why included tests for 
criteria succeed.

Original issue reported on code.google.com by [email protected] on 27 Jan 2011 at 11:24

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant