my dog learned polymorphism*
The moose likes Object Relational Mapping and the fly likes JPQL WHERE IN Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "JPQL WHERE IN Help" Watch "JPQL WHERE IN Help" New topic
Author

JPQL WHERE IN Help

Norman Davis
Greenhorn

Joined: Feb 14, 2011
Posts: 2
Hello to all -

I'm working with JPA for the first time, and have come across a problem I can't seem to find a solution for, executing a WHERE IN native query.

Entity Class:


From EntityManagerController:


The RegistrantsFilter isn't being used currently, I can't even run a test case. The Exception thrown isn't much help, just an EJB exception subsequently being thrown by an AbortProcessException.

I'm using EclipseLink JPA 2.0 to a MySQL 5.x database w/ Glassfish 3.1. My persistence.xml works with 4 other entity classes with basic CRUD operations, but this WHERE IN is starting to be the death of me. I've tried different data structures, removing the () around :branches, tried making the List generic with integers, everything.

Any help would be greatly appreciated.
James Sutherland
Ranch Hand

Joined: Oct 01, 2007
Posts: 553
Do you mean "named" query or "native" query?

You annotation is a named JPQL query, not an native SQL query.

This should work for JPQL, but remove the brackets. Also ensure you are using at least the EclipseLink 2.1 release.
For a native SQL query you cannot bind a collection, as it is not a valid SQL type.

What error are you getting? If you have something else masking the error, put a try catch around the query getResutList and dump the exception, or enable logging.

TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
 
 
subject: JPQL WHERE IN Help