openjpa-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Christian Defoy" <christian.de...@gmail.com>
Subject Getting a group of entities by ID
Date Wed, 18 Jul 2007 13:39:17 GMT
Hello,

I can't find an easy way of retrieving a group of entities by
specifying only their IDs. For example, if I want to get shapes with
IDs 1, 2, 4 and 6, do I have to do the following query or is there a
better way?

SELECT x FROM shape x WHERE x.id = 1 OR x.id = 2 OR x.id = 4 OR x.id = 6

I was thinking of something more along the lines of the IN SQL
statement ("WHERE x.id IN (1,2,4,6)") but I haven't found anything to
do this.  Using SQL queries, I was able to retrieve my shapes but
OpenJPA does one select to retrieve the IDs (my SQL query with the IN
clause) and then one select per shape it retrieves.  That is no
different than me doing a find for every shape myself...

Thanks in advance!

Christian

Mime
View raw message