use of org.hibernate.boot.jaxb.mapping.spi.JaxbAssociationOverride in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getAssociationOverrides.
/**
* @param mergeWithAnnotations Whether to use Java annotations for this
* element, if present and not disabled by the XMLContext defaults.
* In some contexts (such as an element-collection mapping) merging
*/
private AssociationOverrides getAssociationOverrides(List<JaxbAssociationOverride> elements, XMLContext.Default defaults, boolean mergeWithAnnotations) {
List<AssociationOverride> attributes = buildAssociationOverrides(elements, defaults);
if (mergeWithAnnotations && defaults.canUseJavaAnnotations()) {
AssociationOverride annotation = getPhysicalAnnotation(AssociationOverride.class);
addAssociationOverrideIfNeeded(annotation, attributes);
AssociationOverrides annotations = getPhysicalAnnotation(AssociationOverrides.class);
if (annotations != null) {
for (AssociationOverride current : annotations.value()) {
addAssociationOverrideIfNeeded(current, attributes);
}
}
}
if (attributes.size() > 0) {
AnnotationDescriptor ad = new AnnotationDescriptor(AssociationOverrides.class);
ad.setValue("value", attributes.toArray(new AssociationOverride[attributes.size()]));
return AnnotationFactory.create(ad);
} else {
return null;
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbAssociationOverride in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method buildAssociationOverrides.
private List<AssociationOverride> buildAssociationOverrides(List<JaxbAssociationOverride> elements, XMLContext.Default defaults) {
List<AssociationOverride> overrides = new ArrayList<>();
if (elements != null && elements.size() > 0) {
for (JaxbAssociationOverride current : elements) {
AnnotationDescriptor override = new AnnotationDescriptor(AssociationOverride.class);
copyAttribute(override, "name", current.getName(), true);
override.setValue("joinColumns", getJoinColumns(current.getJoinColumn(), false));
JoinTable joinTable = buildJoinTable(current.getJoinTable(), defaults);
if (joinTable != null) {
override.setValue("joinTable", joinTable);
}
overrides.add(AnnotationFactory.create(override));
}
}
return overrides;
}
Aggregations