use of javax.persistence.PrimaryKeyJoinColumns in project hibernate-orm by hibernate.
the class AnnotationBinder method makeInheritanceJoinColumns.
private static Ejb3JoinColumn[] makeInheritanceJoinColumns(XClass clazzToProcess, MetadataBuildingContext context, InheritanceState inheritanceState, PersistentClass superEntity) {
Ejb3JoinColumn[] inheritanceJoinedColumns = null;
final boolean hasJoinedColumns = inheritanceState.hasParents() && InheritanceType.JOINED.equals(inheritanceState.getType());
if (hasJoinedColumns) {
//@Inheritance(JOINED) subclass need to link back to the super entity
PrimaryKeyJoinColumns jcsAnn = clazzToProcess.getAnnotation(PrimaryKeyJoinColumns.class);
boolean explicitInheritanceJoinedColumns = jcsAnn != null && jcsAnn.value().length != 0;
if (explicitInheritanceJoinedColumns) {
int nbrOfInhJoinedColumns = jcsAnn.value().length;
PrimaryKeyJoinColumn jcAnn;
inheritanceJoinedColumns = new Ejb3JoinColumn[nbrOfInhJoinedColumns];
for (int colIndex = 0; colIndex < nbrOfInhJoinedColumns; colIndex++) {
jcAnn = jcsAnn.value()[colIndex];
inheritanceJoinedColumns[colIndex] = Ejb3JoinColumn.buildJoinColumn(jcAnn, null, superEntity.getIdentifier(), null, null, context);
}
} else {
PrimaryKeyJoinColumn jcAnn = clazzToProcess.getAnnotation(PrimaryKeyJoinColumn.class);
inheritanceJoinedColumns = new Ejb3JoinColumn[1];
inheritanceJoinedColumns[0] = Ejb3JoinColumn.buildJoinColumn(jcAnn, null, superEntity.getIdentifier(), null, null, context);
}
LOG.trace("Subclass joined column(s) created");
} else {
if (clazzToProcess.isAnnotationPresent(PrimaryKeyJoinColumns.class) || clazzToProcess.isAnnotationPresent(PrimaryKeyJoinColumn.class)) {
LOG.invalidPrimaryKeyJoinColumnAnnotation(clazzToProcess.getName());
}
}
return inheritanceJoinedColumns;
}
use of javax.persistence.PrimaryKeyJoinColumns in project cloudstack by apache.
the class DbUtil method getPrimaryKeyJoinColumns.
public static PrimaryKeyJoinColumn[] getPrimaryKeyJoinColumns(Class<?> clazz) {
PrimaryKeyJoinColumn pkjc = clazz.getAnnotation(PrimaryKeyJoinColumn.class);
if (pkjc != null) {
return new PrimaryKeyJoinColumn[] { pkjc };
}
PrimaryKeyJoinColumns pkjcs = clazz.getAnnotation(PrimaryKeyJoinColumns.class);
if (pkjcs != null) {
return pkjcs.value();
}
return null;
}
Aggregations