Search in sources :

Example 1 with JaxbHbmTuplizerType

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

the class AttributesHelper method processPropertiesGroup.

private static void processPropertiesGroup(final MappingDocument mappingDocument, final Callback callback, final JaxbHbmPropertiesType propertiesGroupJaxbMapping, String logicalTableName, NaturalIdMutability naturalIdMutability) {
    final String name = propertiesGroupJaxbMapping.getName();
    final AttributeRole attributeRole = callback.getAttributeSourceContainer().getAttributeRoleBase().append(name);
    final AttributePath attributePath = callback.getAttributeSourceContainer().getAttributePathBase().append(name);
    final EmbeddableSourceVirtualImpl embeddable = new EmbeddableSourceVirtualImpl(mappingDocument, callback, new EmbeddableSourceContainer() {

        @Override
        public AttributeRole getAttributeRoleBase() {
            return attributeRole;
        }

        @Override
        public AttributePath getAttributePathBase() {
            return attributePath;
        }

        @Override
        public ToolingHintContext getToolingHintContextBaselineForEmbeddable() {
            return callback.getAttributeSourceContainer().getToolingHintContext();
        }
    }, propertiesGroupJaxbMapping.getAttributes(), logicalTableName, naturalIdMutability, propertiesGroupJaxbMapping);
    // fake the JAXB mapping...
    final EmbeddableMapping embeddableMapping = new EmbeddableMapping() {

        @Override
        public String getClazz() {
            return null;
        }

        @Override
        public List<JaxbHbmTuplizerType> getTuplizer() {
            return Collections.emptyList();
        }

        @Override
        public String getParent() {
            return null;
        }
    };
    final EmbeddedAttributeMapping attributeMapping = new EmbeddedAttributeMapping() {

        @Override
        public boolean isUnique() {
            return propertiesGroupJaxbMapping.isUnique();
        }

        @Override
        public EmbeddableMapping getEmbeddableMapping() {
            return embeddableMapping;
        }

        @Override
        public String getName() {
            return propertiesGroupJaxbMapping.getName();
        }

        @Override
        public String getAccess() {
            return null;
        }

        @Override
        public List<JaxbHbmToolingHintType> getToolingHints() {
            return Collections.emptyList();
        }
    };
    // todo : make the virtual embedded attribute
    final SingularAttributeSourceEmbedded virtualAttribute = new AbstractSingularAttributeSourceEmbeddedImpl(mappingDocument, attributeMapping, embeddable, naturalIdMutability) {

        @Override
        public boolean isVirtualAttribute() {
            return true;
        }

        @Override
        public Boolean isInsertable() {
            return propertiesGroupJaxbMapping.isInsert();
        }

        @Override
        public Boolean isUpdatable() {
            return propertiesGroupJaxbMapping.isUpdate();
        }

        @Override
        public boolean isBytecodeLazy() {
            return false;
        }

        @Override
        public XmlElementMetadata getSourceType() {
            return XmlElementMetadata.PROPERTIES;
        }

        @Override
        public String getXmlNodeName() {
            return null;
        }

        @Override
        public AttributePath getAttributePath() {
            return attributePath;
        }

        @Override
        public AttributeRole getAttributeRole() {
            return attributeRole;
        }

        @Override
        public boolean isIncludedInOptimisticLocking() {
            return false;
        }

        @Override
        public ToolingHintContext getToolingHintContext() {
            return mappingDocument.getToolingHintContext();
        }
    };
    callback.addAttributeSource(virtualAttribute);
}
Also used : AttributeRole(org.hibernate.boot.model.source.spi.AttributeRole) SingularAttributeSourceEmbedded(org.hibernate.boot.model.source.spi.SingularAttributeSourceEmbedded) EmbeddedAttributeMapping(org.hibernate.boot.model.source.spi.EmbeddedAttributeMapping) JaxbHbmToolingHintType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmToolingHintType) JaxbHbmTuplizerType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTuplizerType) ToolingHintContext(org.hibernate.boot.model.source.spi.ToolingHintContext) EmbeddableMapping(org.hibernate.boot.model.source.spi.EmbeddableMapping) AttributePath(org.hibernate.boot.model.source.spi.AttributePath)

Example 2 with JaxbHbmTuplizerType

use of org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTuplizerType 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)

Aggregations

JaxbHbmTuplizerType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTuplizerType)2 JaxbHbmHibernateMapping (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping)1 JaxbHbmRootEntityType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType)1 JaxbHbmSimpleIdType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmSimpleIdType)1 JaxbHbmToolingHintType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmToolingHintType)1 AttributePath (org.hibernate.boot.model.source.spi.AttributePath)1 AttributeRole (org.hibernate.boot.model.source.spi.AttributeRole)1 EmbeddableMapping (org.hibernate.boot.model.source.spi.EmbeddableMapping)1 EmbeddedAttributeMapping (org.hibernate.boot.model.source.spi.EmbeddedAttributeMapping)1 SingularAttributeSourceEmbedded (org.hibernate.boot.model.source.spi.SingularAttributeSourceEmbedded)1 ToolingHintContext (org.hibernate.boot.model.source.spi.ToolingHintContext)1 DynamicMapEntityTuplizer (org.hibernate.tuple.entity.DynamicMapEntityTuplizer)1