Search in sources :

Example 1 with JaxbMappedSuperclass

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

the class XMLContext method addClass.

private void addClass(List<? extends ManagedType> managedTypes, String packageName, Default defaults, List<String> addedClasses) {
    for (ManagedType element : managedTypes) {
        String className = buildSafeClassName(element.getClazz(), packageName);
        if (managedTypeOverride.containsKey(className)) {
            // maybe switch it to warn?
            throw new IllegalStateException("Duplicate XML entry for " + className);
        }
        addedClasses.add(className);
        managedTypeOverride.put(className, element);
        Default mergedDefaults = new Default();
        // Apply entity mapping defaults
        mergedDefaults.overrideWithCatalogAndSchema(defaults);
        // ... then apply entity settings
        Default fileDefaults = new Default();
        fileDefaults.setMetadataComplete(element.isMetadataComplete());
        fileDefaults.setAccess(element.getAccess());
        mergedDefaults.overrideWithCatalogAndSchema(fileDefaults);
        // ... and we get the merged defaults for that entity
        defaultsOverride.put(className, mergedDefaults);
        LOG.debugf("Adding XML overriding information for %s", className);
        if (element instanceof JaxbEntity) {
            addEntityListenerClasses(((JaxbEntity) element).getEntityListeners(), packageName, addedClasses);
        } else if (element instanceof JaxbMappedSuperclass) {
            addEntityListenerClasses(((JaxbMappedSuperclass) element).getEntityListeners(), packageName, addedClasses);
        }
    }
}
Also used : ManagedType(org.hibernate.boot.jaxb.mapping.spi.ManagedType) JaxbMappedSuperclass(org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Example 2 with JaxbMappedSuperclass

use of org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass in project quarkus by quarkusio.

the class JpaJandexScavenger method enlistOrmXmlMapping.

private void enlistOrmXmlMapping(Collector collector, JaxbEntityMappings mapping) {
    String packageName = mapping.getPackage();
    String packagePrefix = packageName == null ? "" : packageName + ".";
    JaxbPersistenceUnitMetadata metadata = mapping.getPersistenceUnitMetadata();
    JaxbPersistenceUnitDefaults defaults = metadata == null ? null : metadata.getPersistenceUnitDefaults();
    if (defaults != null) {
        enlistOrmXmlMappingListeners(collector, packagePrefix, defaults.getEntityListeners());
    }
    for (JaxbEntity entity : mapping.getEntity()) {
        enlistOrmXmlMappingManagedClass(collector, packagePrefix, entity, "entity");
    }
    for (JaxbMappedSuperclass mappedSuperclass : mapping.getMappedSuperclass()) {
        enlistOrmXmlMappingManagedClass(collector, packagePrefix, mappedSuperclass, "mapped-superclass");
    }
    for (JaxbEmbeddable embeddable : mapping.getEmbeddable()) {
        String name = safeGetClassName(packagePrefix, embeddable, "embeddable");
        enlistExplicitClass(collector, name);
    }
    for (JaxbConverter converter : mapping.getConverter()) {
        collector.potentialCdiBeanTypes.add(DotName.createSimple(qualifyIfNecessary(packagePrefix, converter.getClazz())));
    }
}
Also used : JaxbConverter(org.hibernate.boot.jaxb.mapping.spi.JaxbConverter) JaxbMappedSuperclass(org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass) JaxbEmbeddable(org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddable) JaxbPersistenceUnitDefaults(org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitDefaults) JaxbPersistenceUnitMetadata(org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadata) JaxbEntity(org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)

Aggregations

JaxbEntity (org.hibernate.boot.jaxb.mapping.spi.JaxbEntity)2 JaxbMappedSuperclass (org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass)2 JaxbConverter (org.hibernate.boot.jaxb.mapping.spi.JaxbConverter)1 JaxbEmbeddable (org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddable)1 JaxbPersistenceUnitDefaults (org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitDefaults)1 JaxbPersistenceUnitMetadata (org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadata)1 ManagedType (org.hibernate.boot.jaxb.mapping.spi.ManagedType)1