EmbeddedIdentifierMappingImpl implements SingleAttributeIdentifierMapping
This commit is contained in:
parent
638d1b2d46
commit
4806398ecc
|
@ -37,7 +37,8 @@ import org.hibernate.sql.ast.tree.from.TableReference;
|
|||
*
|
||||
* @author Andrea Boriero
|
||||
*/
|
||||
public class EmbeddedIdentifierMappingImpl extends AbstractCompositeIdentifierMapping {
|
||||
public class EmbeddedIdentifierMappingImpl extends AbstractCompositeIdentifierMapping
|
||||
implements SingleAttributeIdentifierMapping {
|
||||
private final String name;
|
||||
private final PropertyAccess propertyAccess;
|
||||
|
||||
|
@ -177,4 +178,14 @@ public class EmbeddedIdentifierMappingImpl extends AbstractCompositeIdentifierMa
|
|||
return (Collection) getEmbeddableTypeDescriptor().getAttributeMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyAccess getPropertyAccess() {
|
||||
return propertyAccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.sql.results.graph.entity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.hibernate.LockMode;
|
||||
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
|
||||
import org.hibernate.metamodel.mapping.EntityIdentifierMapping;
|
||||
|
@ -16,7 +14,7 @@ import org.hibernate.metamodel.mapping.EntityRowIdMapping;
|
|||
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
|
||||
import org.hibernate.metamodel.mapping.EntityVersionMapping;
|
||||
import org.hibernate.metamodel.mapping.ManagedMappingType;
|
||||
import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping;
|
||||
import org.hibernate.metamodel.mapping.MappingType;
|
||||
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
||||
import org.hibernate.persister.entity.AbstractEntityPersister;
|
||||
import org.hibernate.query.EntityIdentifierNavigablePath;
|
||||
|
@ -70,29 +68,14 @@ public abstract class AbstractEntityResultGraphNode extends AbstractFetchParent
|
|||
|
||||
final EntityIdentifierMapping identifierMapping = entityDescriptor.getIdentifierMapping();
|
||||
|
||||
final EntityIdentifierNavigablePath identifierNavigablePath = new EntityIdentifierNavigablePath( navigablePath, attributeName( identifierMapping ) );
|
||||
if ( navigablePath.getParent() == null && !creationState.forceIdentifierSelection() ) {
|
||||
identifierResult = null;
|
||||
if ( identifierMapping instanceof SingleAttributeIdentifierMapping ) {
|
||||
identifierMapping.createDomainResult(
|
||||
new EntityIdentifierNavigablePath(
|
||||
navigablePath,
|
||||
attributeName( identifierMapping )
|
||||
),
|
||||
entityTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
else {
|
||||
visitCompositeIdentifierMapping( navigablePath, creationState, identifierMapping, entityTableGroup );
|
||||
}
|
||||
visitIdentifierMapping( identifierNavigablePath, creationState, identifierMapping, entityTableGroup );
|
||||
}
|
||||
else {
|
||||
identifierResult = identifierMapping.createDomainResult(
|
||||
new EntityIdentifierNavigablePath(
|
||||
navigablePath,
|
||||
attributeName( identifierMapping )
|
||||
),
|
||||
identifierNavigablePath,
|
||||
entityTableGroup,
|
||||
null,
|
||||
creationState
|
||||
|
@ -139,39 +122,42 @@ public abstract class AbstractEntityResultGraphNode extends AbstractFetchParent
|
|||
}
|
||||
}
|
||||
|
||||
private void visitCompositeIdentifierMapping(
|
||||
NavigablePath navigablePath,
|
||||
private void visitIdentifierMapping(
|
||||
EntityIdentifierNavigablePath navigablePath,
|
||||
DomainResultCreationState creationState,
|
||||
EntityIdentifierMapping identifierMapping,
|
||||
TableGroup entityTableGroup) {
|
||||
ManagedMappingType mappingType = (ManagedMappingType) identifierMapping.getPartMappingType();
|
||||
fetches = new ArrayList<>();
|
||||
mappingType.visitAttributeMappings(
|
||||
attributeMapping -> {
|
||||
if ( attributeMapping instanceof ToOneAttributeMapping ) {
|
||||
( (ToOneAttributeMapping) attributeMapping ).getForeignKeyDescriptor().createDomainResult(
|
||||
new EntityIdentifierNavigablePath(
|
||||
navigablePath,
|
||||
attributeName( identifierMapping )
|
||||
),
|
||||
entityTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
final MappingType mappingType = identifierMapping.getPartMappingType();
|
||||
if ( mappingType instanceof ManagedMappingType ) {
|
||||
( (ManagedMappingType) mappingType ).visitAttributeMappings(
|
||||
attributeMapping -> {
|
||||
if ( attributeMapping instanceof ToOneAttributeMapping ) {
|
||||
( (ToOneAttributeMapping) attributeMapping ).getForeignKeyDescriptor().createDomainResult(
|
||||
navigablePath,
|
||||
entityTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
else {
|
||||
attributeMapping.createDomainResult(
|
||||
navigablePath,
|
||||
entityTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
attributeMapping.createDomainResult(
|
||||
new EntityIdentifierNavigablePath(
|
||||
navigablePath,
|
||||
attributeName( identifierMapping )
|
||||
),
|
||||
entityTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
else {
|
||||
identifierMapping.createDomainResult(
|
||||
navigablePath,
|
||||
entityTableGroup,
|
||||
null,
|
||||
creationState
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
protected EntityDiscriminatorMapping getDiscriminatorMapping(
|
||||
|
|
Loading…
Reference in New Issue