
| Key: |
NUCJPA-190
|
| Type: |
Bug
|
| Status: |
Closed
|
| Resolution: |
Cannot Reproduce
|
| Priority: |
Major
|
| Assignee: |
Unassigned
|
| Reporter: |
Marcel Overdijk
|
| Votes: |
0
|
| Watchers: |
1
|
|
If you were logged in you would be able to see more operations.
|
|
|
|
I'm using Datanucleus with Spring Data JPA on App Engine.
The basis persisting and queries go well. But as I was exploring further I stumbled against a problem with ParameterExpressions. Which does not seem to work.
When having:
{code}
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(User.class);
Root<User> root = cq.from(User.class);
ParameterExpression<String> username = cb.parameter(String.class);
cq.select(root);
cq.where(cb.like(root.<String> get("username"), username));
TypedQuery<User> tq = em.createQuery(cq);
tq.setParameter(username, "man" + "%");
List<User> users = tq.getResultList();
{code}
See also full test case I will attach after creating this issue.
The error I get is:
INFO: >> Exception thrown retrieving objects
java.lang.IllegalArgumentException: Query has parameter "-1" supplied at execution yet the query doesnt make use of this parameter
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:461)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:419)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:56)
at org.datanucleus.test.Main.main(Main.java:108)
Caused by: org.datanucleus.store.query.QueryInvalidParametersException: Query has parameter "-1" supplied at execution yet the query doesnt make use of this parameter
at org.datanucleus.store.query.Query.applyImplicitParameterValueToCompilation(Query.java:881)
at org.datanucleus.store.query.Query.setImplicitParameter(Query.java:828)
at org.datanucleus.store.rdbms.query.JPQLQuery.setImplicitParameter(JPQLQuery.java:136)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:457)
... 3 more
Note that with Spring Data JPA I was getting a little bit different exception, but I don't know the exact code created by Spring Data JPA.
Nevertheless when experimenting with the query builder/criteria I found above issue.
Btw this is the error I see with Spring Data JPA:
Numbered parameter syntax starting ? but isnt followed by numeric!; nested exception is javax.persistence.PersistenceException: Numbered parameter syntax starting ? but isnt followed by numeric!
|
|
Description
|
I'm using Datanucleus with Spring Data JPA on App Engine.
The basis persisting and queries go well. But as I was exploring further I stumbled against a problem with ParameterExpressions. Which does not seem to work.
When having:
{code}
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<User> cq = cb.createQuery(User.class);
Root<User> root = cq.from(User.class);
ParameterExpression<String> username = cb.parameter(String.class);
cq.select(root);
cq.where(cb.like(root.<String> get("username"), username));
TypedQuery<User> tq = em.createQuery(cq);
tq.setParameter(username, "man" + "%");
List<User> users = tq.getResultList();
{code}
See also full test case I will attach after creating this issue.
The error I get is:
INFO: >> Exception thrown retrieving objects
java.lang.IllegalArgumentException: Query has parameter "-1" supplied at execution yet the query doesnt make use of this parameter
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:461)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:419)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:56)
at org.datanucleus.test.Main.main(Main.java:108)
Caused by: org.datanucleus.store.query.QueryInvalidParametersException: Query has parameter "-1" supplied at execution yet the query doesnt make use of this parameter
at org.datanucleus.store.query.Query.applyImplicitParameterValueToCompilation(Query.java:881)
at org.datanucleus.store.query.Query.setImplicitParameter(Query.java:828)
at org.datanucleus.store.rdbms.query.JPQLQuery.setImplicitParameter(JPQLQuery.java:136)
at org.datanucleus.api.jpa.JPAQuery.setParameter(JPAQuery.java:457)
... 3 more
Note that with Spring Data JPA I was getting a little bit different exception, but I don't know the exact code created by Spring Data JPA.
Nevertheless when experimenting with the query builder/criteria I found above issue.
Btw this is the error I see with Spring Data JPA:
Numbered parameter syntax starting ? but isnt followed by numeric!; nested exception is javax.persistence.PersistenceException: Numbered parameter syntax starting ? but isnt followed by numeric! |
Show » |
Sort Order:
|
NUCJPA-188?As I'm seeing this my logs (note the missing space between ?-1ORDER):
11:27:15,215 DEBUG [DataNucleus.Query] - JPQL Query : Compiling "SELECT FROM org.mycomp.domain.User DN_THIS WHERE DN_THIS.username LIKE ?-1ORDER BY DN_THIS.username ASC"
Exception:
javax.persistence.PersistenceException: Numbered parameter syntax starting ? but isnt followed by numeric!