use of org.hibernate.metamodel.mapping.EntityMappingType in project hibernate-orm by hibernate.
the class DiscriminatedAssociationAttributeMapping method disassemble.
@Override
public Object disassemble(Object value, SharedSessionContractImplementor session) {
if (value == null) {
return null;
}
final EntityMappingType concreteMappingType = determineConcreteType(value, session);
final EntityIdentifierMapping identifierMapping = concreteMappingType.getIdentifierMapping();
final Object discriminator = discriminatorMapping.getModelPart().resolveDiscriminatorForEntityType(concreteMappingType);
final Object identifier = identifierMapping.getIdentifier(value);
return new Object[] { discriminatorMapping.getDiscriminatorPart().disassemble(discriminator, session), identifierMapping.disassemble(identifier, session) };
}
use of org.hibernate.metamodel.mapping.EntityMappingType in project hibernate-orm by hibernate.
the class DiscriminatedAssociationAttributeMapping method breakDownJdbcValues.
@Override
public void breakDownJdbcValues(Object domainValue, JdbcValueConsumer valueConsumer, SharedSessionContractImplementor session) {
final EntityMappingType concreteMappingType = determineConcreteType(domainValue, session);
final Object discriminator = discriminatorMapping.getModelPart().resolveDiscriminatorForEntityType(concreteMappingType);
final Object disassembledDiscriminator = discriminatorMapping.getDiscriminatorPart().disassemble(discriminator, session);
valueConsumer.consume(disassembledDiscriminator, discriminatorMapping.getDiscriminatorPart());
final EntityIdentifierMapping identifierMapping = concreteMappingType.getIdentifierMapping();
final Object identifier = identifierMapping.getIdentifier(domainValue);
final Object disassembledKey = discriminatorMapping.getKeyPart().disassemble(identifier, session);
valueConsumer.consume(disassembledKey, discriminatorMapping.getKeyPart());
}
use of org.hibernate.metamodel.mapping.EntityMappingType in project hibernate-orm by hibernate.
the class DiscriminatedAssociationAttributeMapping method forEachDisassembledJdbcValue.
@Override
public int forEachDisassembledJdbcValue(Object value, Clause clause, int offset, JdbcValuesConsumer valuesConsumer, SharedSessionContractImplementor session) {
if (value != null) {
if (value.getClass().isArray()) {
final Object[] values = (Object[]) value;
valuesConsumer.consume(offset, values[0], discriminatorMapping.getDiscriminatorPart().getJdbcMapping());
valuesConsumer.consume(offset + 1, values[1], discriminatorMapping.getKeyPart().getJdbcMapping());
} else {
final EntityMappingType concreteMappingType = determineConcreteType(value, session);
final Object discriminator = discriminatorMapping.getModelPart().resolveDiscriminatorForEntityType(concreteMappingType);
final Object disassembledDiscriminator = discriminatorMapping.getDiscriminatorPart().disassemble(discriminator, session);
valuesConsumer.consume(offset, disassembledDiscriminator, discriminatorMapping.getDiscriminatorPart().getJdbcMapping());
final EntityIdentifierMapping identifierMapping = concreteMappingType.getIdentifierMapping();
final Object identifier = identifierMapping.getIdentifier(value);
final Object disassembledKey = discriminatorMapping.getKeyPart().disassemble(identifier, session);
valuesConsumer.consume(offset + 1, disassembledKey, discriminatorMapping.getKeyPart().getJdbcMapping());
}
}
return 2;
}
use of org.hibernate.metamodel.mapping.EntityMappingType in project hibernate-orm by hibernate.
the class ResultSetMappingProcessor method createSuffixedResultBuilder.
private DynamicResultBuilderEntityStandard createSuffixedResultBuilder(EntityMappingType entityMapping, String tableAlias, String suffix, LockMode lockMode, NavigablePath navigablePath) {
final SQLLoadable loadable = (SQLLoadable) entityMapping.getEntityPersister();
final DynamicResultBuilderEntityStandard resultBuilderEntity = new DynamicResultBuilderEntityStandard(entityMapping, tableAlias, navigablePath);
resultBuilderEntity.setLockMode(lockMode);
final String[] identifierAliases = loadable.getIdentifierAliases(suffix);
resultBuilderEntity.addIdColumnAliases(identifierAliases);
resultBuilderEntity.setDiscriminatorAlias(loadable.getDiscriminatorAlias(suffix));
if (loadable.hasIdentifierProperty()) {
resultBuilderEntity.addProperty(loadable.getIdentifierPropertyName(), identifierAliases);
}
for (String propertyName : loadable.getPropertyNames()) {
final String[] columnAliases = loadable.getSubclassPropertyColumnAliases(propertyName, suffix);
final Type propertyType = loadable.getPropertyType(propertyName);
addFetchBuilder(suffix, loadable, resultBuilderEntity, tableAlias, identifierAliases, propertyName, columnAliases, propertyType);
}
return resultBuilderEntity;
}
use of org.hibernate.metamodel.mapping.EntityMappingType in project hibernate-orm by hibernate.
the class StandardEntityGraphTraversalStateImpl method appliesTo.
private boolean appliesTo(FetchParent fetchParent) {
if (currentGraphContext == null || !(fetchParent instanceof EntityResultGraphNode)) {
return false;
}
final EntityResultGraphNode entityFetchParent = (EntityResultGraphNode) fetchParent;
final EntityMappingType entityFetchParentMappingType = entityFetchParent.getEntityValuedModelPart().getEntityMappingType();
assert currentGraphContext.getGraphedType() instanceof EntityDomainType;
final EntityDomainType entityDomainType = (EntityDomainType) currentGraphContext.getGraphedType();
return entityDomainType.getHibernateEntityName().equals(entityFetchParentMappingType.getEntityName());
}
Aggregations