Search in sources :

Example 1 with JaxbEntity

use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method getNamedQueries.

private NamedQueries getNamedQueries(ManagedType root, XMLContext.Default defaults) {
    // TODO avoid the Proxy Creation (@NamedQueries) when possible
    List<NamedQuery> queries = root instanceof JaxbEntity ? buildNamedQueries(((JaxbEntity) root).getNamedQuery(), defaults, classLoaderAccess) : new ArrayList<>();
    if (defaults.canUseJavaAnnotations()) {
        NamedQuery annotation = getPhysicalAnnotation(NamedQuery.class);
        addNamedQueryIfNeeded(annotation, queries);
        NamedQueries annotations = getPhysicalAnnotation(NamedQueries.class);
        if (annotations != null) {
            for (NamedQuery current : annotations.value()) {
                addNamedQueryIfNeeded(current, queries);
            }
        }
    }
    if (queries.size() > 0) {
        AnnotationDescriptor ad = new AnnotationDescriptor(NamedQueries.class);
        ad.setValue("value", queries.toArray(new NamedQuery[queries.size()]));
        return AnnotationFactory.create(ad);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) NamedQueries(jakarta.persistence.NamedQueries) NamedQuery(jakarta.persistence.NamedQuery) JaxbNamedQuery(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedQuery) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Example 2 with JaxbEntity

use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method getNamedEntityGraphs.

private NamedEntityGraphs getNamedEntityGraphs(ManagedType root, XMLContext.Default defaults) {
    List<NamedEntityGraph> queries = root instanceof JaxbEntity ? buildNamedEntityGraph(((JaxbEntity) root).getNamedEntityGraph(), defaults, classLoaderAccess) : new ArrayList<>();
    if (defaults.canUseJavaAnnotations()) {
        NamedEntityGraph annotation = getPhysicalAnnotation(NamedEntityGraph.class);
        addNamedEntityGraphIfNeeded(annotation, queries);
        NamedEntityGraphs annotations = getPhysicalAnnotation(NamedEntityGraphs.class);
        if (annotations != null) {
            for (NamedEntityGraph current : annotations.value()) {
                addNamedEntityGraphIfNeeded(current, queries);
            }
        }
    }
    if (queries.size() > 0) {
        AnnotationDescriptor ad = new AnnotationDescriptor(NamedEntityGraphs.class);
        ad.setValue("value", queries.toArray(new NamedEntityGraph[queries.size()]));
        return AnnotationFactory.create(ad);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) NamedEntityGraphs(jakarta.persistence.NamedEntityGraphs) NamedEntityGraph(jakarta.persistence.NamedEntityGraph) JaxbNamedEntityGraph(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedEntityGraph) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Example 3 with JaxbEntity

use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method getNamedNativeQueries.

private NamedNativeQueries getNamedNativeQueries(ManagedType root, XMLContext.Default defaults) {
    List<NamedNativeQuery> queries = root instanceof JaxbEntity ? buildNamedNativeQueries(((JaxbEntity) root).getNamedNativeQuery(), defaults, classLoaderAccess) : new ArrayList<>();
    if (defaults.canUseJavaAnnotations()) {
        NamedNativeQuery annotation = getPhysicalAnnotation(NamedNativeQuery.class);
        addNamedNativeQueryIfNeeded(annotation, queries);
        NamedNativeQueries annotations = getPhysicalAnnotation(NamedNativeQueries.class);
        if (annotations != null) {
            for (NamedNativeQuery current : annotations.value()) {
                addNamedNativeQueryIfNeeded(current, queries);
            }
        }
    }
    if (queries.size() > 0) {
        AnnotationDescriptor ad = new AnnotationDescriptor(NamedNativeQueries.class);
        ad.setValue("value", queries.toArray(new NamedNativeQuery[queries.size()]));
        return AnnotationFactory.create(ad);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbNamedNativeQuery(org.hibernate.boot.jaxb.mapping.spi.JaxbNamedNativeQuery) NamedNativeQuery(jakarta.persistence.NamedNativeQuery) NamedNativeQueries(jakarta.persistence.NamedNativeQueries) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Example 4 with JaxbEntity

use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method getSqlResultSetMappings.

private SqlResultSetMappings getSqlResultSetMappings(ManagedType root, XMLContext.Default defaults) {
    List<SqlResultSetMapping> results = root instanceof JaxbEntity ? buildSqlResultsetMappings(((JaxbEntity) root).getSqlResultSetMapping(), defaults, classLoaderAccess) : new ArrayList<>();
    if (defaults.canUseJavaAnnotations()) {
        SqlResultSetMapping annotation = getPhysicalAnnotation(SqlResultSetMapping.class);
        addSqlResultsetMappingIfNeeded(annotation, results);
        SqlResultSetMappings annotations = getPhysicalAnnotation(SqlResultSetMappings.class);
        if (annotations != null) {
            for (SqlResultSetMapping current : annotations.value()) {
                addSqlResultsetMappingIfNeeded(current, results);
            }
        }
    }
    if (results.size() > 0) {
        AnnotationDescriptor ad = new AnnotationDescriptor(SqlResultSetMappings.class);
        ad.setValue("value", results.toArray(new SqlResultSetMapping[results.size()]));
        return AnnotationFactory.create(ad);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) SqlResultSetMappings(jakarta.persistence.SqlResultSetMappings) SqlResultSetMapping(jakarta.persistence.SqlResultSetMapping) JaxbSqlResultSetMapping(org.hibernate.boot.jaxb.mapping.spi.JaxbSqlResultSetMapping) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Example 5 with JaxbEntity

use of org.hibernate.boot.jaxb.mapping.spi.JaxbEntity in project hibernate-orm by hibernate.

the class JPAXMLOverriddenAnnotationReader method getInheritance.

private Inheritance getInheritance(ManagedType root, XMLContext.Default defaults) {
    JaxbInheritance element = root instanceof JaxbEntity ? ((JaxbEntity) root).getInheritance() : null;
    if (element != null) {
        AnnotationDescriptor ad = new AnnotationDescriptor(Inheritance.class);
        InheritanceType strategy = element.getStrategy();
        if (strategy != null) {
            ad.setValue("strategy", strategy);
        }
        return AnnotationFactory.create(ad);
    } else if (defaults.canUseJavaAnnotations()) {
        return getPhysicalAnnotation(Inheritance.class);
    } else {
        return null;
    }
}
Also used : AnnotationDescriptor(org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor) JaxbInheritance(org.hibernate.boot.jaxb.mapping.spi.JaxbInheritance) Inheritance(jakarta.persistence.Inheritance) JaxbInheritance(org.hibernate.boot.jaxb.mapping.spi.JaxbInheritance) InheritanceType(jakarta.persistence.InheritanceType) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Aggregations

JaxbEntity (org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)16 AnnotationDescriptor (org.hibernate.annotations.common.annotationfactory.AnnotationDescriptor)13 SecondaryTable (jakarta.persistence.SecondaryTable)2 JaxbMappedSuperclass (org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass)2 JaxbPersistenceUnitDefaults (org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitDefaults)2 JaxbPersistenceUnitMetadata (org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadata)2 JaxbSecondaryTable (org.hibernate.boot.jaxb.mapping.spi.JaxbSecondaryTable)2 CollectionTable (jakarta.persistence.CollectionTable)1 Convert (jakarta.persistence.Convert)1 DiscriminatorColumn (jakarta.persistence.DiscriminatorColumn)1 DiscriminatorType (jakarta.persistence.DiscriminatorType)1 DiscriminatorValue (jakarta.persistence.DiscriminatorValue)1 Entity (jakarta.persistence.Entity)1 Inheritance (jakarta.persistence.Inheritance)1 InheritanceType (jakarta.persistence.InheritanceType)1 JoinTable (jakarta.persistence.JoinTable)1 NamedEntityGraph (jakarta.persistence.NamedEntityGraph)1 NamedEntityGraphs (jakarta.persistence.NamedEntityGraphs)1 NamedNativeQueries (jakarta.persistence.NamedNativeQueries)1 NamedNativeQuery (jakarta.persistence.NamedNativeQuery)1