Search in sources :

Example 1 with JaxbHbmRootEntityType

use of org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType in project hibernate-orm by hibernate.

the class EntityHierarchyBuilder method indexMappingDocument.

/**
	 * Called for each mapping document.
	 *
	 * @param mappingDocument The {@code hbm.xml} document to index
	 */
public void indexMappingDocument(MappingDocument mappingDocument) {
    log.tracef("Indexing mapping document [%s] for purpose of building entity hierarchy ordering", mappingDocument.getOrigin());
    final JaxbHbmHibernateMapping mappingBinding = mappingDocument.getDocumentRoot();
    // iterate all root class definitions at the hibernate-mapping level
    for (JaxbHbmRootEntityType jaxbRootEntity : mappingBinding.getClazz()) {
        // we can immediately handle <class/> elements in terms of creating the hierarchy entry
        final RootEntitySourceImpl rootEntitySource = new RootEntitySourceImpl(mappingDocument, jaxbRootEntity);
        entitySourceByNameMap.put(rootEntitySource.getEntityNamingSource().getEntityName(), rootEntitySource);
        final EntityHierarchySourceImpl hierarchy = new EntityHierarchySourceImpl(rootEntitySource);
        entityHierarchyList.add(hierarchy);
        linkAnyWaiting(mappingDocument, rootEntitySource);
        // process any of its nested sub-entity definitions
        processRootEntitySubEntityElements(mappingDocument, jaxbRootEntity, rootEntitySource);
    }
    // iterate all discriminator-based subclass definitions at the hibernate-mapping level
    for (JaxbHbmDiscriminatorSubclassEntityType discriminatorSubclassEntityBinding : mappingBinding.getSubclass()) {
        processTopLevelSubClassBinding(mappingDocument, discriminatorSubclassEntityBinding);
    }
    // iterate all joined-subclass definitions at the hibernate-mapping level
    for (JaxbHbmJoinedSubclassEntityType joinedSubclassEntityBinding : mappingBinding.getJoinedSubclass()) {
        processTopLevelSubClassBinding(mappingDocument, joinedSubclassEntityBinding);
    }
    // iterate all union-subclass definitions at the hibernate-mapping level
    for (JaxbHbmUnionSubclassEntityType unionSubclassEntityBinding : mappingBinding.getUnionSubclass()) {
        processTopLevelSubClassBinding(mappingDocument, unionSubclassEntityBinding);
    }
}
Also used : JaxbHbmUnionSubclassEntityType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmUnionSubclassEntityType) JaxbHbmDiscriminatorSubclassEntityType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmDiscriminatorSubclassEntityType) JaxbHbmRootEntityType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType) JaxbHbmJoinedSubclassEntityType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmJoinedSubclassEntityType) JaxbHbmHibernateMapping(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping)

Example 2 with JaxbHbmRootEntityType

use of org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType in project hibernate-orm by hibernate.

the class AbstractEntitySourceImpl method buildFilterSources.

private FilterSource[] buildFilterSources() {
    //todo for now, i think all EntityElement should support this.
    if (JaxbHbmRootEntityType.class.isInstance(jaxbEntityMapping())) {
        final JaxbHbmRootEntityType jaxbClassElement = (JaxbHbmRootEntityType) jaxbEntityMapping();
        final int size = jaxbClassElement.getFilter().size();
        if (size == 0) {
            return NO_FILTER_SOURCES;
        }
        FilterSource[] results = new FilterSource[size];
        for (int i = 0; i < size; i++) {
            JaxbHbmFilterType element = jaxbClassElement.getFilter().get(i);
            results[i] = new FilterSourceImpl(sourceMappingDocument(), element);
        }
        return results;
    } else {
        return NO_FILTER_SOURCES;
    }
}
Also used : FilterSource(org.hibernate.boot.model.source.spi.FilterSource) JaxbHbmRootEntityType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType) JaxbHbmFilterType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmFilterType)

Example 3 with JaxbHbmRootEntityType

use of org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType in project hibernate-orm by hibernate.

the class EntityModeConverterTest method generateXml.

private JaxbHbmHibernateMapping generateXml(boolean includeEntityMode) throws Exception {
    JaxbHbmHibernateMapping hm = new JaxbHbmHibernateMapping();
    JaxbHbmRootEntityType clazz = new JaxbHbmRootEntityType();
    JaxbHbmTuplizerType tuplizer = new JaxbHbmTuplizerType();
    tuplizer.setClazz(DynamicMapEntityTuplizer.class.getCanonicalName());
    if (includeEntityMode) {
        tuplizer.setEntityMode(EntityMode.MAP);
    }
    clazz.getTuplizer().add(tuplizer);
    JaxbHbmSimpleIdType id = new JaxbHbmSimpleIdType();
    clazz.setId(id);
    hm.getClazz().add(clazz);
    return hm;
}
Also used : JaxbHbmSimpleIdType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSimpleIdType) JaxbHbmTuplizerType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTuplizerType) JaxbHbmRootEntityType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType) JaxbHbmHibernateMapping(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping) DynamicMapEntityTuplizer(org.hibernate.tuple.entity.DynamicMapEntityTuplizer)

Example 4 with JaxbHbmRootEntityType

use of org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType in project hibernate-orm by hibernate.

the class GenerationTimingConverterTest method testMashallAttributeWithNullGenerationTiming.

@Test
public void testMashallAttributeWithNullGenerationTiming() throws Exception {
    JaxbHbmHibernateMapping hm = new JaxbHbmHibernateMapping();
    JaxbHbmRootEntityType clazz = new JaxbHbmRootEntityType();
    JaxbHbmSimpleIdType id = new JaxbHbmSimpleIdType();
    JaxbHbmBasicAttributeType att = new JaxbHbmBasicAttributeType();
    att.setName("attributeName");
    clazz.getAttributes().add(att);
    clazz.setId(id);
    hm.getClazz().add(clazz);
    XmlBindingChecker.checkValidGeneration(hm);
}
Also used : JaxbHbmSimpleIdType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSimpleIdType) JaxbHbmRootEntityType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType) JaxbHbmBasicAttributeType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmBasicAttributeType) JaxbHbmHibernateMapping(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping) Test(org.junit.Test)

Aggregations

JaxbHbmRootEntityType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType)4 JaxbHbmHibernateMapping (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping)3 JaxbHbmSimpleIdType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSimpleIdType)2 JaxbHbmBasicAttributeType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmBasicAttributeType)1 JaxbHbmDiscriminatorSubclassEntityType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmDiscriminatorSubclassEntityType)1 JaxbHbmFilterType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmFilterType)1 JaxbHbmJoinedSubclassEntityType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmJoinedSubclassEntityType)1 JaxbHbmTuplizerType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTuplizerType)1 JaxbHbmUnionSubclassEntityType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmUnionSubclassEntityType)1 FilterSource (org.hibernate.boot.model.source.spi.FilterSource)1 DynamicMapEntityTuplizer (org.hibernate.tuple.entity.DynamicMapEntityTuplizer)1 Test (org.junit.Test)1