/**
* Parse @NamedQuery.
*/
private void parseNamedQueries(AnnotatedElement el, NamedQuery... queries) {
QueryMetaData meta;
for (NamedQuery query : queries) {
if (StringUtils.isEmpty(query.name()))
throw new MetaDataException(_loc.get("no-query-name", el));
if (StringUtils.isEmpty(query.query()))
throw new MetaDataException(_loc.get("no-query-string",
query.name(), el));
if (_log.isTraceEnabled())
_log.trace(_loc.get("parse-query", query.name()));
meta = getRepository().getCachedQueryMetaData(null, query.name());
if (meta != null) {
if (_log.isWarnEnabled())
_log.warn(_loc.get("dup-query", query.name(), el));
return;
}
meta = getRepository().addQueryMetaData(null, query.name());
meta.setQueryString(query.query());
meta.setLanguage(JPQLParser.LANG_JPQL);
for (QueryHint hint : query.hints())
meta.addHint(hint.name(), hint.value());
meta.setSource(getSourceFile(), (el instanceof Class) ? el : null,
meta.SRC_ANNOTATIONS);
if (isMetaDataMode())
meta.setSourceMode(MODE_META);
else if (isMappingMode())
meta.setSourceMode(MODE_MAPPING);
else
meta.setSourceMode(MODE_QUERY);
}
}