Search in sources :

Example 1 with JaxbHbmToolingHintType

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

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

the class Helper method collectToolingHints.

private static ToolingHintContext collectToolingHints(ToolingHintContext baseline, ToolingHintContainer toolingHintContainer, boolean onlyInheritable) {
    final ToolingHintContext localToolingHints = new ToolingHintContext(baseline);
    if (toolingHintContainer != null && toolingHintContainer.getToolingHints() != null) {
        for (JaxbHbmToolingHintType toolingHintJaxbBinding : toolingHintContainer.getToolingHints()) {
            if (onlyInheritable && !toolingHintJaxbBinding.isInheritable()) {
                continue;
            }
            final String hintName = toolingHintJaxbBinding.getName();
            ToolingHint toolingHint = localToolingHints.getToolingHint(hintName);
            if (toolingHint == null) {
                toolingHint = new ToolingHint(hintName, toolingHintJaxbBinding.isInheritable());
                localToolingHints.add(toolingHint);
            } else {
                if (baseline != null) {
                    final ToolingHint inherited = baseline.getToolingHint(hintName);
                    if (toolingHint == inherited) {
                        // overriding inherited meta attribute. HBX-621 & HBX-793
                        toolingHint = new ToolingHint(hintName, toolingHintJaxbBinding.isInheritable());
                        localToolingHints.add(toolingHint);
                    }
                }
            }
            toolingHint.addValue(toolingHintJaxbBinding.getValue());
        }
    }
    return localToolingHints;
}
Also used : JaxbHbmToolingHintType(org.hibernate.boot.jaxb.hbm.spi.JaxbHbmToolingHintType) ToolingHintContext(org.hibernate.boot.model.source.spi.ToolingHintContext) ToolingHint(org.hibernate.boot.model.source.spi.ToolingHint)

Aggregations

JaxbHbmToolingHintType (org.hibernate.boot.jaxb.hbm.spi.JaxbHbmToolingHintType)2 ToolingHintContext (org.hibernate.boot.model.source.spi.ToolingHintContext)2 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 ToolingHint (org.hibernate.boot.model.source.spi.ToolingHint)1