I'm trying to exclude a bunch of results from a database SELECT using the "NOT IN" keywords, but the exclusion list is still being returned. Using JPQL (JPA2.0) my query looks like:
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);
exclusionList is a StringBuffer. There is no error reported that I can see, but the id's in the exclusion list are still returned. Is there an alternative JPQL way of doing this?
Thanks in advance.
I think the mistake is in foo
. What is foo you have to defined it any where.
Write FooEntity foo
instead of FooEntity fooEntity
Have a look on the following URL.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.