diff --git a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MethodStoreQuery.java b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MethodStoreQuery.java index a69be2ece..141ac7850 100644 --- a/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MethodStoreQuery.java +++ b/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/MethodStoreQuery.java @@ -248,6 +248,10 @@ public class MethodStoreQuery } if (!Modifier.isStatic(meth.getModifiers())) throw new UserException(_loc.get("method-not-static", meth)); + if (!ResultObjectProvider.class.isAssignableFrom( + meth.getReturnType())) + throw new UserException(_loc.get("method-return-type-invalid", + meth, meth.getReturnType())); _meth = meth; } diff --git a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties index 89cf8454c..9de8e4926 100644 --- a/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties +++ b/openjpa-kernel/src/main/resources/org/apache/openjpa/kernel/localizer.properties @@ -300,6 +300,9 @@ bad-method-class: You set the method name of this openjpa.MethodQL query to \ qualify the class name or to import its package into this query if the \ class is not in the query candidate class'' package. method-not-static: Method "{0}" named in the MethodQL query must be static. +method-return-type-invalid: Method "{0}" named in the MethodQL query must \ + have a return type that is assignable from ResultObjectProvider. Return \ + type is: {1}. no-method: You must set the query filter to the name of the method to execute \ for this MethodQL query instance. method-error: There was an error invoking method "{0}" with arguments "{1}".