JPQL query does not use "NOT IN" command

I am trying to exclude a bunch of results from the SELECT database using the keywords "NOT IN", but the list of exceptions is still being returned. Using JPQL (JPA2.0), my query looks like this:

Query query = em.createQuery("SELECT foo.id FROM FooEntity fooEntity WHERE foo.id NOT IN ('" + exclusionList.toString() + "') ORDER BY foo.id").setFirstResult(startPosition).setMaxResults(numberOfAppsToReturn); 

exception List is a StringBuffer. It is reported that I do not see an error, but the identifier in the list of exceptions is still returned. Is there an alternative to JPQL for this?

Thanks in advance.

+4
source share
1 answer

I think the error is in foo . What you need to determine anywhere.

Write FooEntity foo instead of FooEntity fooEntity

Take a look at the following URL.

Jpql how NOT to select something

+4
source

All Articles