use of org.hibernate.boot.model.source.spi.IdentifierSourceNonAggregatedComposite in project hibernate-orm by hibernate.
the class ModelBinder method bindNonAggregatedCompositeEntityIdentifier.
private void bindNonAggregatedCompositeEntityIdentifier(MappingDocument mappingDocument, EntityHierarchySourceImpl hierarchySource, RootClass rootEntityDescriptor) {
final IdentifierSourceNonAggregatedComposite identifierSource = (IdentifierSourceNonAggregatedComposite) hierarchySource.getIdentifierSource();
final Component cid = new Component(mappingDocument.getMetadataCollector(), rootEntityDescriptor);
cid.setKey(true);
rootEntityDescriptor.setIdentifier(cid);
final String idClassName = extractIdClassName(identifierSource);
bindComponent(mappingDocument, hierarchySource.getRoot().getAttributeRoleBase().append("<id>").getFullPath(), identifierSource.getEmbeddableSource(), cid, idClassName, rootEntityDescriptor.getClassName(), null, idClassName == null, false, null);
if (idClassName != null) {
// we also need to bind the "id mapper". ugh, terrible name. Basically we need to
// create a virtual (embedded) composite for the non-aggregated attributes on the entity
// itself.
final Component mapper = new Component(mappingDocument.getMetadataCollector(), rootEntityDescriptor);
bindComponent(mappingDocument, hierarchySource.getRoot().getAttributeRoleBase().append(ID_MAPPER_PATH_PART).getFullPath(), identifierSource.getEmbeddableSource(), mapper, rootEntityDescriptor.getClassName(), null, null, true, false, null);
rootEntityDescriptor.setIdentifierMapper(mapper);
Property property = new Property();
property.setName(PropertyPath.IDENTIFIER_MAPPER_PROPERTY);
property.setUpdateable(false);
property.setInsertable(false);
property.setValue(mapper);
property.setPropertyAccessorName("embedded");
rootEntityDescriptor.addProperty(property);
}
finishBindingCompositeIdentifier(mappingDocument, rootEntityDescriptor, identifierSource, cid, null);
}
Aggregations