Ok that sounds logical, I tried writing a sql server query "SELECT * FROM MyTable WHERE ID IN ()" and indeed this isn't correct SQL. However "SELECT * FROM MyTable WHERE ID IN (null)" works, but this is different from an empty list.
-----Oorspronkelijk bericht----- Van: Boblitz John [mailto:john.bobl...@bertschi.com] Verzonden: dinsdag 23 augustus 2011 17:44 Aan: 'users@openjpa.apache.org' Onderwerp: AW: illogical java.lang.IllegalArgumentException: Input parameter "ids" is empty > -----Ursprüngliche Nachricht----- > Von: Henno Vermeulen [mailto:he...@huizemolenaar.nl] > Gesendet: Dienstag, 23. August 2011 15:29 > An: 'users@openjpa.apache.org' > Betreff: illogical java.lang.IllegalArgumentException: Input > parameter "ids" is empty > > I have a query that goes like "SELECT e.id, ... FROM ... > WHERE e.id IN :ids". Parameter ids is a list of ids. When it > is empty and I execute the query, OpenJPA throws > java.lang.IllegalArgumentException: Input parameter "ids" is empty. > > Why not just return an empty list? I feel this is much like > iterating over an empty Collection: by not throwing an > exception you get less complex code than when you have to > write an if statement to handle empty collections. > > Regards, > Henno Vermeulen > Huize Molenaar > Hello, I would think it has a lot to do with the fact that the underlying SQL cant be executed! The SQL IN clause requires a list of values and if they are not provided, SQL will throw the error. Further, an empty list is indicative of a query which found no entries satisfying a given criteria (and implicitly, that the criteria were valid.) The exception indicates that the criteria itself are invalid. Anyway, just my 2 pence ...  John ---- Who is General Failure, and why is he reading my hard disk?