persistence@glassfish.java.net

Re: Problem binding collections to queries

From: Wouter van Reeven <wouter_at_van.reeven.nl>
Date: Thu, 7 Feb 2008 10:40:35 +0100

On Thu, Feb 07, 2008 at 10:36:28AM +0100, Christian Kerwer wrote:
> Thanks! There seems already beeing an issue for this #2484.
>
> Also I'm disappointed that this won't work ether:
> ... where id in ( select l_Id from IN(:planningObjectIdList) l_Id )
>
> It seems JPA is far from cool.

Well, all JPA queries are translated to SQL in the end. So everytime you write a
JPA query, you'll have to be sure that the resulting SQL query is valid. The
problem with your approach is that the Array of Longs isn't stored in the
database. If you'd like to use a subquery, be sure to create some temp table,
store the ids in that table, execute the query and remove the ids again. It's
cumbersome, but it should work.


HTH, Wouter van Reeven

-- 
People: "If she weighs the same as a Duck, she's made of wood!"
Sir Bedevere: "And therefore...?"