Parameters do not work on NativeQuery
See original GitHub issueWhen I run this code:
String cql = "SELECT ids FROM something WHERE value = ?1";
Query q = entityManager.createNativeQuery(cql, MyClass.class);
q.setParameter(1, value);
it throws an exception:
com.impetus.kundera.query.QueryHandlerException: No named parameter present for query
at com.impetus.kundera.query.KunderaQuery.setParameterValue(KunderaQuery.java:755)
at com.impetus.kundera.query.KunderaQuery.setParameter(KunderaQuery.java:718)
at com.impetus.kundera.query.QueryImpl.setParameter(QueryImpl.java:473)
looking a the Kundera code (QueryResolver.java), it doesn’t support parameters for NativeQueries. The list of valid parameters it built up initFilter(), which is called from postParsingInit(). However, postParsingInit is not called if the query is native:
if (!isNative)
{
...
parser.parse();
kunderaQuery.postParsingInit();
...
}
Issue Analytics
- State:
- Created 10 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
java - Native query with named parameter fails with "Not all ...
Named parameters are not supported by JPA in native queries, only for JPQL. You must use positional parameters. Named parameters follow the rules...
Read more >JPA Query Parameters Usage - Baeldung
We may use either positional or named parameters, but we must not mix them within the same query. 4.1. Positional Parameters.
Read more >Spring Data JPA Native Query - Named parameters are not ...
[Solved]-Spring Data JPA Native Query - Named parameters are not being registered-Springboot ... The single quotes around your parameters is probably the issue....
Read more >JPA Native Query example with Spring Boot - BezKoder
In this tutorial, you will know how to use Spring Data JPA Native Query example (with parameters) in Spring Boot. I will show...
Read more >Parameters are not passed to proxied native Query instance ...
I try to migrate from Spring Data JPA 1.11.10 to Spring Data JPA 2.x. ... When doing so all native queries won't work...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@mevivs
Since setParameter is not supported on native queries (includes named native queries), what is the suggested way to execute parameterized native queries except constructing the query with parameter and value in entirety?
Thank you!
Regards, Malcolm
+1