> -----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?

Reply via email to