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