Search in sources :

Example 1 with EmbeddableMapping

use of org.hibernate.boot.model.source.spi.EmbeddableMapping 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)

Aggregations

JaxbHbmToolingHintType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmToolingHintType)1 JaxbHbmTuplizerType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmTuplizerType)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