Author: mprudhom Date: Thu Sep 14 11:21:19 2006 New Revision: 443432 URL: http://svn.apache.org/viewvc?view=rev&rev=443432 Log: Fixed bug where NamedNativeQuery/NamedNativeQueries was not being examined when looking up named queries, which could result in them not being found if the metadata has not yet been parsed completely
Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java?view=diff&rev=443432&r1=443431&r2=443432 ============================================================================== --- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java (original) +++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/PersistenceMetaDataFactory.java Thu Sep 14 11:21:19 2006 @@ -30,6 +30,8 @@ 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,12 +279,28 @@ 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; } private boolean hasNamedQuery(String query, NamedQuery... queries) { for (NamedQuery q : queries) { + if (query.equals(q.name())) + return true; + } + return false; + } + + private boolean hasNamedNativeQuery(String query, + NamedNativeQuery... queries) { + for (NamedNativeQuery q : queries) { if (query.equals(q.name())) return true; }