Win a copy of Machine Learning for Business: Using Amazon SageMaker and JupyterE this week in the Jython/Python forum
or Object Design Style Guide in the Object-Oriented programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

Trouble setting in class

Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to use a named query with an IN clause, but it does not work;

My IDE forces to add the parenthesis around the :mailingIDList, all of the documentation I find about using the IN clause says I do not need the parenthesis.
I am using eclipseLink 2.5.0.

Here is what the method containing the entityManager executing the JPA looks like:

Not sure what the problem is, if I remove the parentheisis I get a syntax error on the query in my IDE.
I get a failure with the parenthesis around the :mailingIDList of;
You have attempted to set a value of type class java.util.HashSet for parameter mailingIDList with expected type of class java.lang.Integer from query string SELECT m FROM MarketingMailingIDMRMXRef m WHERE m.mailingID IN (:mailingIDList).

I think my problem is with EclipseLink not allowing me to not use a parenthesis, but how do I get around that?
Posts: 7
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think the problem is not with paranthesis .

You are trying to assign a Set to Integer type. That's why this error is thrown.

You can try another variation of setParameter method , which has arguments String and List.

Hope this helps.
Posts: 21842
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem is with the parentheses. Right now, you're saying that you want to filter the mailingId using a list of Set<Integer>. If you provide parentheses in the IN query, you can only provide a single element (or multiple if you provide multiple parameters within the parentheses). If you omit the parentheses you can provide a collection of elements.
Whoever got anywhere by being normal? Just ask this exceptional tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!