/**
* Parse @NamedNativeQuery.
*/
private void parseNamedNativeQueries(AnnotatedElement el,
NamedNativeQuery... queries) {
QueryMetaData meta;
for (NamedNativeQuery query : queries) {
if (StringUtils.isEmpty(query.name()))
throw new MetaDataException(_loc.get("no-native-query-name",
el));
if (StringUtils.isEmpty(query.query()))
throw new MetaDataException(_loc.get("no-native-query-string",
query.name(), el));
if (_log.isTraceEnabled())
_log.trace(_loc.get("parse-native-query", query.name()));
meta = getRepository().getCachedQueryMetaData(null, query.name());
if (meta != null) {
if (_log.isWarnEnabled())
_log.warn(_loc.get("dup-query", query.name(), el));
continue;
}
meta = getRepository().addQueryMetaData(null, query.name());
meta.setQueryString(query.query());
meta.setLanguage(QueryLanguages.LANG_SQL);
Class res = query.resultClass();
if (ImplHelper.isManagedType(getConfiguration(), res))
meta.setCandidateType(res);
else if (!void.class.equals(res))
meta.setResultType(res);
if (!StringUtils.isEmpty(query.resultSetMapping()))
meta.setResultSetMappingName(query.resultSetMapping());
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);
}
}