openjpa-users mailing list archives

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

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 = 1 OR = 2 OR = 4 OR = 6

I was thinking of something more along the lines of the IN SQL
statement ("WHERE 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!


View raw message