|Re: IN clause in @NamedNativeQuery [message #647083 is a reply to message #646377]
||Tue, 04 January 2011 14:35
| Chris Delahunt
Registered: July 2009
I do not believe 328378 is related, as 328378 deals with JPQL queries but the first post mentions using NamedNativeQuery - straight SQL queries.
Can you please post the exception you are getting? My guess is you are attempting to pass in a collection to
@NamedNativeQuery (name="XXX",query="SELECT [COLUMNS] FROM TABLE WHERE COLUMN IN ?1")
for the ?1 parameter, where as in the working query you have each parameter defined individually as in ('A','B','C'). Please note that Native queries are passed to the database exactly as defined, so I would suggest instead using:
@NamedNativeQuery (name="XXX",query="SELECT [COLUMNS] FROM TABLE WHERE COLUMN IN(?1,?2,?3)")
and then passing a collection with 3 arguments.
Or, you can try a JPQL query:
@NamedQuery (name="XXX",query="SELECT [COLUMNS] FROM TABLE WHERE COLUMN IN(?1)")
JPQL processing will create the appropriate sql based on the number of arguments if a collection is used for the ?1 parameter.
Powered by FUDForum
. Page generated in 0.01774 seconds