use of javax.jdo.JDOQLTypedQuery in project datanucleus-api-jdo by datanucleus.
the class JDOQLTypedQueryImpl method saveAsNamedQuery.
/* (non-Javadoc)
* @see javax.jdo.JDOQLTypedQuery#saveAsNamedQuery(java.lang.String)
*/
@Override
public JDOQLTypedQuery<T> saveAsNamedQuery(String name) {
assertIsOpen();
JDOPersistenceManagerFactory.checkJDOPermission(JDOPermission.GET_METADATA);
QueryMetaData qmd = new QueryMetaData(name);
qmd.setLanguage(Query.LANGUAGE_JDOQL);
Query query = getInternalQuery();
qmd.setQuery(query.toString());
qmd.setResultClass(query.getResultClassName());
qmd.setUnique(query.isUnique());
Map<String, Object> queryExts = query.getExtensions();
if (queryExts != null && !queryExts.isEmpty()) {
Iterator<Map.Entry<String, Object>> queryExtsIter = queryExts.entrySet().iterator();
while (queryExtsIter.hasNext()) {
Map.Entry<String, Object> queryExtEntry = queryExtsIter.next();
qmd.addExtension(queryExtEntry.getKey(), "" + queryExtEntry.getValue());
}
}
query.getExecutionContext().getMetaDataManager().registerNamedQuery(qmd);
return this;
}
Aggregations