Search in sources :

Example 1 with Embeddable

use of jakarta.persistence.Embeddable in project hibernate-orm by hibernate.

the class AbstractPropertyHolder method buildHierarchyColumnOverride.

private void buildHierarchyColumnOverride(XClass element) {
    XClass current = element;
    Map<String, Column[]> columnOverride = new HashMap<>();
    Map<String, ColumnTransformer> columnTransformerOverride = new HashMap<>();
    Map<String, JoinColumn[]> joinColumnOverride = new HashMap<>();
    Map<String, JoinTable> joinTableOverride = new HashMap<>();
    Map<String, ForeignKey> foreignKeyOverride = new HashMap<>();
    while (current != null && !context.getBootstrapContext().getReflectionManager().toXClass(Object.class).equals(current)) {
        if (current.isAnnotationPresent(Entity.class) || current.isAnnotationPresent(MappedSuperclass.class) || current.isAnnotationPresent(Embeddable.class)) {
            // FIXME is embeddable override?
            Map<String, Column[]> currentOverride = buildColumnOverride(current, getPath());
            Map<String, ColumnTransformer> currentTransformerOverride = buildColumnTransformerOverride(current, getPath());
            Map<String, JoinColumn[]> currentJoinOverride = buildJoinColumnOverride(current, getPath());
            Map<String, JoinTable> currentJoinTableOverride = buildJoinTableOverride(current, getPath());
            Map<String, ForeignKey> currentForeignKeyOverride = buildForeignKeyOverride(current, getPath());
            // subclasses have precedence over superclasses
            currentOverride.putAll(columnOverride);
            // subclasses have precedence over superclasses
            currentTransformerOverride.putAll(columnTransformerOverride);
            // subclasses have precedence over superclasses
            currentJoinOverride.putAll(joinColumnOverride);
            // subclasses have precedence over superclasses
            currentJoinTableOverride.putAll(joinTableOverride);
            // subclasses have precedence over superclasses
            currentForeignKeyOverride.putAll(foreignKeyOverride);
            columnOverride = currentOverride;
            columnTransformerOverride = currentTransformerOverride;
            joinColumnOverride = currentJoinOverride;
            joinTableOverride = currentJoinTableOverride;
            foreignKeyOverride = currentForeignKeyOverride;
        }
        current = current.getSuperclass();
    }
    holderColumnOverride = columnOverride.size() > 0 ? columnOverride : null;
    holderColumnTransformerOverride = columnTransformerOverride.size() > 0 ? columnTransformerOverride : null;
    holderJoinColumnOverride = joinColumnOverride.size() > 0 ? joinColumnOverride : null;
    holderJoinTableOverride = joinTableOverride.size() > 0 ? joinTableOverride : null;
    holderForeignKeyOverride = foreignKeyOverride.size() > 0 ? foreignKeyOverride : null;
}
Also used : HashMap(java.util.HashMap) ForeignKey(jakarta.persistence.ForeignKey) XClass(org.hibernate.annotations.common.reflection.XClass) Embeddable(jakarta.persistence.Embeddable) ColumnTransformer(org.hibernate.annotations.ColumnTransformer) JoinTable(jakarta.persistence.JoinTable)

Aggregations

Embeddable (jakarta.persistence.Embeddable)1 ForeignKey (jakarta.persistence.ForeignKey)1 JoinTable (jakarta.persistence.JoinTable)1 HashMap (java.util.HashMap)1 ColumnTransformer (org.hibernate.annotations.ColumnTransformer)1 XClass (org.hibernate.annotations.common.reflection.XClass)1