diff --git a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java index c2f2c305c..39e686dbf 100644 --- a/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java +++ b/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java @@ -30,6 +30,8 @@ import javax.persistence.Entity; import javax.persistence.MappedSuperclass; import javax.persistence.NamedQueries; import javax.persistence.NamedQuery; +import javax.persistence.NamedNativeQueries; +import javax.persistence.NamedNativeQuery; import org.apache.openjpa.lib.conf.Configurable; import org.apache.openjpa.lib.conf.Configuration; @@ -277,6 +279,13 @@ public class PersistenceMetaDataFactory hasNamedQuery(queryName, ((NamedQueries) cls.getAnnotation (NamedQueries.class)).value())) return cls; + if (cls.isAnnotationPresent(NamedNativeQuery.class) && hasNamedNativeQuery + (queryName, (NamedNativeQuery) cls.getAnnotation(NamedNativeQuery.class))) + return cls; + if (cls.isAnnotationPresent(NamedNativeQueries.class) && + hasNamedNativeQuery(queryName, ((NamedNativeQueries) cls.getAnnotation + (NamedNativeQueries.class)).value())) + return cls; } return null; } @@ -289,6 +298,15 @@ public class PersistenceMetaDataFactory return false; } + private boolean hasNamedNativeQuery(String query, + NamedNativeQuery... queries) { + for (NamedNativeQuery q : queries) { + if (query.equals(q.name())) + return true; + } + return false; + } + @Override protected MetaDataFilter newMetaDataFilter() { return new ClassAnnotationMetaDataFilter(new Class[]{