use of org.hibernate.boot.jaxb.mapping.spi.JaxbStoredProcedureParameter in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method buildNamedStoreProcedureQueries.
public static List<NamedStoredProcedureQuery> buildNamedStoreProcedureQueries(List<JaxbNamedStoredProcedureQuery> elements, XMLContext.Default defaults, ClassLoaderAccess classLoaderAccess) {
List<NamedStoredProcedureQuery> namedStoredProcedureQueries = new ArrayList<>();
for (JaxbNamedStoredProcedureQuery element : elements) {
AnnotationDescriptor ann = new AnnotationDescriptor(NamedStoredProcedureQuery.class);
copyAttribute(ann, "name", element.getName(), true);
copyAttribute(ann, "procedure-name", element.getProcedureName(), true);
List<StoredProcedureParameter> storedProcedureParameters = new ArrayList<>();
for (JaxbStoredProcedureParameter parameterElement : element.getParameter()) {
AnnotationDescriptor parameterDescriptor = new AnnotationDescriptor(StoredProcedureParameter.class);
copyAttribute(parameterDescriptor, "name", parameterElement.getName(), false);
ParameterMode modeValue = parameterElement.getMode();
if (modeValue == null) {
parameterDescriptor.setValue("mode", ParameterMode.IN);
} else {
parameterDescriptor.setValue("mode", modeValue);
}
String clazzName = parameterElement.getClazz();
Class<?> clazz;
try {
clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(clazzName, defaults));
} catch (ClassLoadingException e) {
throw new AnnotationException("Unable to find entity-class: " + clazzName, e);
}
parameterDescriptor.setValue("type", clazz);
storedProcedureParameters.add(AnnotationFactory.create(parameterDescriptor));
}
ann.setValue("parameters", storedProcedureParameters.toArray(new StoredProcedureParameter[storedProcedureParameters.size()]));
List<Class<?>> returnClasses = new ArrayList<>();
for (String clazzName : element.getResultClass()) {
Class<?> clazz;
try {
clazz = classLoaderAccess.classForName(XMLContext.buildSafeClassName(clazzName, defaults));
} catch (ClassLoadingException e) {
throw new AnnotationException("Unable to find entity-class: " + clazzName, e);
}
returnClasses.add(clazz);
}
ann.setValue("resultClasses", returnClasses.toArray(new Class[returnClasses.size()]));
ann.setValue("resultSetMappings", element.getResultSetMapping().toArray(new String[0]));
buildQueryHints(element.getHint(), ann);
namedStoredProcedureQueries.add(AnnotationFactory.create(ann));
}
return namedStoredProcedureQueries;
}
Aggregations