Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » eclipselink-2.2.0 link IN Clause(Any way to support dynamic values in static IN parameterized clause )
eclipselink-2.2.0 link IN Clause [message #1771283] Wed, 23 August 2017 16:35 Go to next message
santosh choudhary is currently offline santosh choudharyFriend
Messages: 1
Registered: August 2017
Junior Member

I am using eclipselink-2.2.0, I have a requirement to use only parameterized query and the query has to be static that is I can not build query dynamically according to user inputs.
I tried query like:
select * from companies where companyname in (?)
and passed parameter values like " 'aaa','bbb','ccc','ddd' " (thought it would replace single parameter '?' by passed values) but its not working, I tried to debug eclipselink source but no success for me, is there any way to implement this requirements.
Please let me know if need anything else.

Re: eclipselink-2.2.0 link IN Clause [message #1771397 is a reply to message #1771283] Thu, 24 August 2017 16:10 Go to previous message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1339
Registered: July 2009
Senior Member
Also asked here:

"select * from companies where companyname in (?)" looks like straight SQL, and EclipseLink does not modify the SQL you pass into a native query other than to handle parameter binding. So if you need to pass in multiple parameters, you will have to factor that into the SQL string you pass in, and pass those parameters in separately just as you would to JDBC. Native SQL queries are for people who want something very specific and don't want the provider making decisions on what the SQL should look like for them.

The JPQL and JPA queries allow the provider to create the SQL, and so allow passing in lists and breaking them up for you. Try something like EntityManager.createQuery("Select c from Company c where in :names"); and then pass your list as a parameter to the query.
Previous Topic:Eclipselink reverts merged entities
Next Topic:EclipseLink @TableGenerator Concurrency Issue
Goto Forum:

Current Time: Tue Feb 25 16:51:06 GMT 2020

Powered by FUDForum. Page generated in 0.09153 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top