mirror of https://github.com/apache/openjpa.git
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
git-svn-id: https://svn.apache.org/repos/asf/incubator/openjpa/trunk@443432 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72f7b6b963
commit
fcd072a2c5
|
@ -30,6 +30,8 @@ import javax.persistence.Entity;
|
||||||
import javax.persistence.MappedSuperclass;
|
import javax.persistence.MappedSuperclass;
|
||||||
import javax.persistence.NamedQueries;
|
import javax.persistence.NamedQueries;
|
||||||
import javax.persistence.NamedQuery;
|
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.Configurable;
|
||||||
import org.apache.openjpa.lib.conf.Configuration;
|
import org.apache.openjpa.lib.conf.Configuration;
|
||||||
|
@ -277,6 +279,13 @@ public class PersistenceMetaDataFactory
|
||||||
hasNamedQuery(queryName, ((NamedQueries) cls.getAnnotation
|
hasNamedQuery(queryName, ((NamedQueries) cls.getAnnotation
|
||||||
(NamedQueries.class)).value()))
|
(NamedQueries.class)).value()))
|
||||||
return cls;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -289,6 +298,15 @@ public class PersistenceMetaDataFactory
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean hasNamedNativeQuery(String query,
|
||||||
|
NamedNativeQuery... queries) {
|
||||||
|
for (NamedNativeQuery q : queries) {
|
||||||
|
if (query.equals(q.name()))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MetaDataFilter newMetaDataFilter() {
|
protected MetaDataFilter newMetaDataFilter() {
|
||||||
return new ClassAnnotationMetaDataFilter(new Class[]{
|
return new ClassAnnotationMetaDataFilter(new Class[]{
|
||||||
|
|
Loading…
Reference in New Issue