Search in sources :

Example 1 with Embeddable

use of javax.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<String, Column[]>();
    Map<String, JoinColumn[]> joinColumnOverride = new HashMap<String, JoinColumn[]>();
    Map<String, JoinTable> joinTableOverride = new HashMap<String, JoinTable>();
    Map<String, ForeignKey> foreignKeyOverride = new HashMap<String, ForeignKey>();
    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, 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
            currentJoinOverride.putAll(joinColumnOverride);
            // subclasses have precedence over superclasses
            currentJoinTableOverride.putAll(joinTableOverride);
            // subclasses have precedence over superclasses
            currentForeignKeyOverride.putAll(foreignKeyOverride);
            columnOverride = currentOverride;
            joinColumnOverride = currentJoinOverride;
            joinTableOverride = currentJoinTableOverride;
            foreignKeyOverride = currentForeignKeyOverride;
        }
        current = current.getSuperclass();
    }
    holderColumnOverride = columnOverride.size() > 0 ? columnOverride : 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(javax.persistence.ForeignKey) XClass(org.hibernate.annotations.common.reflection.XClass) Embeddable(javax.persistence.Embeddable) JoinColumn(javax.persistence.JoinColumn) JoinColumn(javax.persistence.JoinColumn) Column(javax.persistence.Column) JoinTable(javax.persistence.JoinTable)

Example 2 with Embeddable

use of javax.persistence.Embeddable in project querydsl by querydsl.

the class RooAnnotationProcessor method createConfiguration.

@Override
protected Configuration createConfiguration(RoundEnvironment roundEnv) {
    Class<? extends Annotation> entity = RooJpaEntity.class;
    Class<? extends Annotation> superType = MappedSuperclass.class;
    Class<? extends Annotation> embeddable = Embeddable.class;
    Class<? extends Annotation> embedded = Embedded.class;
    Class<? extends Annotation> skip = Transient.class;
    DefaultConfiguration conf = new JPAConfiguration(roundEnv, processingEnv, entity, superType, embeddable, embedded, skip);
    conf.setAlternativeEntityAnnotation(RooJpaActiveRecord.class);
    return conf;
}
Also used : JPAConfiguration(com.querydsl.apt.jpa.JPAConfiguration) MappedSuperclass(javax.persistence.MappedSuperclass) DefaultConfiguration(com.querydsl.apt.DefaultConfiguration) Embedded(javax.persistence.Embedded) Transient(javax.persistence.Transient) RooJpaEntity(org.springframework.roo.addon.jpa.entity.RooJpaEntity) Embeddable(javax.persistence.Embeddable)

Aggregations

Embeddable (javax.persistence.Embeddable)2 DefaultConfiguration (com.querydsl.apt.DefaultConfiguration)1 JPAConfiguration (com.querydsl.apt.jpa.JPAConfiguration)1 HashMap (java.util.HashMap)1 Column (javax.persistence.Column)1 Embedded (javax.persistence.Embedded)1 ForeignKey (javax.persistence.ForeignKey)1 JoinColumn (javax.persistence.JoinColumn)1 JoinTable (javax.persistence.JoinTable)1 MappedSuperclass (javax.persistence.MappedSuperclass)1 Transient (javax.persistence.Transient)1 XClass (org.hibernate.annotations.common.reflection.XClass)1 RooJpaEntity (org.springframework.roo.addon.jpa.entity.RooJpaEntity)1