my problem is with this type of request:
select * from SOMETABLE where SOMEFIELD in ('STRING1','STRING2');
The previous code works fine in Sql Developer. The same static query also works fine and returns me some results;
Query nativeQuery = em.createNativeQuery(thePreviousQuery,new someResultSet()); return nativeQuery.getResultList();
But when I try to parameterize this, I run into a problem.
final String parameterizedQuery = "select * from SOMETABLE where SOMEFIELD in (?selectedValues)"; Query nativeQuery = em.createNativeQuery(parameterizedQuery ,new someResultSet()); nativeQuery.setParameter("selectedValues","'STRING1','STRING2'"); return nativeQuery.getResultList();
I have no result (but errors in the console). And when I look at the magazine, I see this:
select * from SOMETABLE where SOMEFIELD in (?) bind => [STRING1,STRING2]
I also tried using quotation marks (with a similar result) or an unordered parameter (: selectedValues), which leads to this error:
SQL Error: Missing IN or OUT parameter at index:: 1
I enventually tried to have the brackets set directly in the parameter, instead of the request, but that didn't work either ...
I could create my request at runtime to fit the first (working) case, but I would rather do it appropriately; that way, if anyone has an idea, I will read them with great interest!
FYI: JPA Version 1.0 Oracle 11G
sql oracle oracle11g jpa
Marvin
source share