Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble setting in class

 
Joe Richard
Ranch Hand
Posts: 78
  • 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?
 
vp reddy
Greenhorn
Posts: 6
Eclipse IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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.
 
Rob Spoor
Sheriff
Pie
Posts: 20751
68
Chrome Eclipse IDE Java 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic