#777 - ENH: Add support for @NamedQuery and @NamedQueries

This commit is contained in:
Robin Bygrave
2016-07-15 23:15:18 +12:00
parent cf13119b49
commit 05eb0bfc55
7 changed files with 96 additions and 12 deletions
@@ -46,6 +46,8 @@ import java.util.Map;
*/
public class DeployBeanDescriptor<T> {
private static final Map<String, String> EMPTY_NAMED_QUERY = new HashMap<String, String>();
private static final Map<String, RawSql> EMPTY_RAW_MAP = new HashMap<String, RawSql>();
private static class PropOrder implements Comparator<DeployBeanProperty> {
@@ -73,6 +75,8 @@ public class DeployBeanDescriptor<T> {
private Map<String, RawSql> namedRawSql;
private Map<String, String> namedQuery;
private EntityType entityType;
private DeployBeanPropertyAssocOne<?> unidirectional;
@@ -1055,6 +1059,23 @@ public class DeployBeanDescriptor<T> {
return serverConfig.getDocStoreConfig().getPersist();
}
/**
* Return the named ORM queries.
*/
public Map<String, String> getNamedQuery() {
return (namedQuery != null) ? namedQuery : EMPTY_NAMED_QUERY;
}
/**
* Add a named query.
*/
public void addNamedQuery(String name, String query) {
if (namedQuery == null) {
namedQuery = new LinkedHashMap<String, String>();
}
namedQuery.put(name, query);
}
/**
* Return the named RawSql queries.
*/