use of org.hibernate.boot.jaxb.mapping.spi.JaxbPrimaryKeyJoinColumn in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method getPrimaryKeyJoinColumns.
/**
* @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 association mapping) merging with
*/
private PrimaryKeyJoinColumns getPrimaryKeyJoinColumns(List<JaxbPrimaryKeyJoinColumn> elements, XMLContext.Default defaults, boolean mergeWithAnnotations) {
PrimaryKeyJoinColumn[] columns = buildPrimaryKeyJoinColumns(elements);
if (mergeWithAnnotations) {
if (columns.length == 0 && defaults.canUseJavaAnnotations()) {
PrimaryKeyJoinColumn annotation = getPhysicalAnnotation(PrimaryKeyJoinColumn.class);
if (annotation != null) {
columns = new PrimaryKeyJoinColumn[] { annotation };
} else {
PrimaryKeyJoinColumns annotations = getPhysicalAnnotation(PrimaryKeyJoinColumns.class);
columns = annotations != null ? annotations.value() : columns;
}
}
}
if (columns.length > 0) {
AnnotationDescriptor ad = new AnnotationDescriptor(PrimaryKeyJoinColumns.class);
ad.setValue("value", columns);
return AnnotationFactory.create(ad);
} else {
return null;
}
}
use of org.hibernate.boot.jaxb.mapping.spi.JaxbPrimaryKeyJoinColumn in project hibernate-orm by hibernate.
the class JPAXMLOverriddenAnnotationReader method buildPrimaryKeyJoinColumns.
private PrimaryKeyJoinColumn[] buildPrimaryKeyJoinColumns(List<JaxbPrimaryKeyJoinColumn> elements) {
PrimaryKeyJoinColumn[] pkJoinColumns = new PrimaryKeyJoinColumn[elements.size()];
int i = 0;
for (JaxbPrimaryKeyJoinColumn element : elements) {
AnnotationDescriptor pkAnn = new AnnotationDescriptor(PrimaryKeyJoinColumn.class);
copyAttribute(pkAnn, "name", element.getName(), false);
copyAttribute(pkAnn, "referenced-column-name", element.getReferencedColumnName(), false);
copyAttribute(pkAnn, "column-definition", element.getColumnDefinition(), false);
pkJoinColumns[i++] = AnnotationFactory.create(pkAnn);
}
return pkJoinColumns;
}
Aggregations