2

I want to write a "IN" clause query in jdoQL similar to the given SQL query below.

SELECT salary FROM employee where empId IN (1021,2013,9872);

my objective is that i have a list of email addressess that i would be providing inside the "IN" clause and would need to get the corresponding smtp mail address for each of the email addresses in the jdoQL.

could some one help me out with this? is there any other workaround for this?

thanks in advance for any help provided.

Papps
  • 61
  • 1
  • 7
  • and what have you tried? you do know that JDOQL is basically Java syntax, so how would you do that in a Java method? – DataNucleus Apr 19 '13 at 13:04

1 Answers1

1

Check this page. Which is very much like this one.

You'll then need something like: empIdList.contains(empId)

Where empIdList is a passed in List<Integer>: query.execute(Arrays.asList(1,2,3));

Muhammad Gelbana
  • 3,890
  • 3
  • 43
  • 81
  • i tried it in this manner String query = "SELECT smtpMailAddress FROM " + UserDetails.class.getName() + " WHERE emailAddress=='292358@tcs.com'|| emailAddress=='244903@tcs.com' || emailAddress=='244963@tcs.com'"; but this works for two addresses and not for three! sure muhammad will try out your method. – Papps Apr 23 '13 at 04:21
  • @MuhammadGelbana I tried to use your method, but it seems that DataNucleus doesn't support delaring param as `List` type. Here is my code: `condition = " idList.contains(id) "; q.declareParameters("List idList"); q.execute(new ArrayList());` – xi.lin Aug 26 '14 at 11:21
  • You are providing an empty `ArrayList` – Muhammad Gelbana Aug 26 '14 at 12:33
  • @MuhammadGelbana Actually I passed a created list in my real code. The error is "Class List for query has not been resolved. Check the query and any imports/aliases specification". However, I succeed with the following way: `condition = " :idList.contains(id) "; q.execute(new ArrayList())` – xi.lin Aug 27 '14 at 02:17