@Retention(value=RUNTIME) @Target(value=METHOD) public @interface EmptyCollectionGuard
Spring repositories methods annotated with this will not crash when running with Iterable parameters which could be empty.
The default behavior of a Database, when receiving a query with empty list arguments - ie, textually '()' - is to return a query syntax error (instead of a more meaningful error message). This forces us to program defensively and prevent queries to run on the DB if the parameters would make it fail.
If you want to reduce this boilerplate you may annotate a DAO method with this annotation, in which case the behavior specified
in SpringDaoMetaAnnotationAspect will be applied, essentially returning 'no results'. The meaning of 'no results' may
vary depending on the expected return type : Object, primitive type, or a collection of these (see the doc on the aspect for
details).
Of course in some case you don't want the result to be "no result". In that case, just don't use that annotation.
Copyright © 2010–2017 Henix, henix.fr. All rights reserved.