Get rid of most walking stuff

This commit is contained in:
Christian Beikov 2022-02-11 10:22:24 +01:00
parent 1a71bb9787
commit 87638a9a2e
39 changed files with 12 additions and 2235 deletions

View File

@ -4,20 +4,15 @@
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.internal;
package org.hibernate.metamodel.mapping.internal;
import org.hibernate.FetchMode;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.profile.Fetch;
import org.hibernate.engine.profile.FetchProfile;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.loader.PropertyPath;
import org.hibernate.persister.collection.AbstractCollectionPersister;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.sql.results.graph.FetchOptions;
import org.hibernate.type.AssociationType;
@ -28,41 +23,6 @@ public final class FetchOptionsHelper {
private FetchOptionsHelper() {
}
/**
* Determine the fetch-style (if one) explicitly set for this association via fetch profiles.
* <p/>
* Note that currently fetch profiles only allow specifying join fetching, so this method currently
* returns either (a) FetchStyle.JOIN or (b) null
*/
public static FetchStyle determineFetchStyleByProfile(
LoadQueryInfluencers loadQueryInfluencers,
EntityPersister persister,
PropertyPath path,
int propertyNumber) {
if ( !loadQueryInfluencers.hasEnabledFetchProfiles() ) {
// perf optimization
return null;
}
// ugh, this stuff has to be made easier...
final String fullPath = path.getFullPath();
final String rootPropertyName = ( (OuterJoinLoadable) persister ).getSubclassPropertyName( propertyNumber );
int pos = fullPath.lastIndexOf( rootPropertyName );
final String relativePropertyPath = pos >= 0
? fullPath.substring( pos )
: rootPropertyName;
final String fetchRole = persister.getEntityName() + '.' + relativePropertyPath;
for ( String profileName : loadQueryInfluencers.getEnabledFetchProfileNames() ) {
final FetchProfile profile = loadQueryInfluencers.getSessionFactory().getFetchProfile( profileName );
final Fetch fetch = profile.getFetchByRole( fetchRole );
if ( fetch != null && Fetch.Style.JOIN == fetch.getStyle() ) {
return FetchStyle.JOIN;
}
}
return null;
}
/**
*
* @param mappingFetchMode The mapping defined fetch mode

View File

@ -78,7 +78,6 @@ import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
import org.hibernate.property.access.internal.ChainedPropertyAccessImpl;
import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;

View File

@ -88,17 +88,6 @@ import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.PropertyMapping;
import org.hibernate.persister.internal.SqlFragmentPredicate;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.internal.CompositionSingularSubAttributesHelper;
import org.hibernate.persister.walking.internal.StandardAnyTypeDefinition;
import org.hibernate.persister.walking.spi.AnyMappingDefinition;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.persister.walking.spi.CollectionDefinition;
import org.hibernate.persister.walking.spi.CollectionElementDefinition;
import org.hibernate.persister.walking.spi.CollectionIndexDefinition;
import org.hibernate.persister.walking.spi.CompositeCollectionElementDefinition;
import org.hibernate.persister.walking.spi.CompositionDefinition;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.query.spi.NavigablePath;
import org.hibernate.query.named.NamedQueryMemento;
@ -123,8 +112,6 @@ import org.hibernate.sql.ast.tree.select.SelectClause;
import org.hibernate.sql.ast.tree.select.SelectStatement;
import org.hibernate.sql.results.graph.DomainResult;
import org.hibernate.sql.results.internal.SqlSelectionImpl;
import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType;
import org.hibernate.type.CollectionType;
import org.hibernate.type.CompositeType;
import org.hibernate.type.EntityType;
@ -2268,186 +2255,10 @@ public abstract class AbstractCollectionPersister
return mappedByProperty;
}
// private class StandardOrderByAliasResolver implements OrderByAliasResolver {
// private final String rootAlias;
//
// private StandardOrderByAliasResolver(String rootAlias) {
// this.rootAlias = rootAlias;
// }
//
// @Override
// public String resolveTableAlias(String columnReference) {
// if ( elementPersister == null ) {
// // we have collection of non-entity elements...
// return rootAlias;
// }
// else {
// return ( (Loadable) elementPersister ).getTableAliasForColumn( columnReference, rootAlias );
// }
// }
// }
public abstract FilterAliasGenerator getFilterAliasGenerator(String rootAlias);
public abstract FilterAliasGenerator getFilterAliasGenerator(TableGroup tableGroup);
// ColectionDefinition impl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public CollectionPersister getCollectionPersister() {
return this;
}
@Override
public CollectionIndexDefinition getIndexDefinition() {
if ( ! hasIndex() ) {
return null;
}
return new CollectionIndexDefinition() {
@Override
public CollectionDefinition getCollectionDefinition() {
return AbstractCollectionPersister.this;
}
@Override
public Type getType() {
return getIndexType();
}
@Override
public EntityDefinition toEntityDefinition() {
if ( !getType().isEntityType() ) {
throw new IllegalStateException( "Cannot treat collection index type as entity" );
}
return (EntityPersister) ( (AssociationType) getIndexType() ).getAssociatedJoinable( getFactory() );
}
@Override
public CompositionDefinition toCompositeDefinition() {
if ( ! getType().isComponentType() ) {
throw new IllegalStateException( "Cannot treat collection index type as composite" );
}
return new CompositeCollectionElementDefinition() {
@Override
public String getName() {
return "index";
}
@Override
public CompositeType getType() {
return (CompositeType) getIndexType();
}
@Override
public boolean isNullable() {
return false;
}
@Override
public AttributeSource getSource() {
// TODO: what if this is a collection w/in an encapsulated composition attribute?
// should return the encapsulated composition attribute instead???
return getOwnerEntityPersister();
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return CompositionSingularSubAttributesHelper.getCompositeCollectionIndexSubAttributes( this );
}
@Override
public CollectionDefinition getCollectionDefinition() {
return AbstractCollectionPersister.this;
}
};
}
@Override
public AnyMappingDefinition toAnyMappingDefinition() {
final Type type = getType();
if ( ! type.isAnyType() ) {
throw new IllegalStateException( "Cannot treat collection index type as ManyToAny" );
}
return new StandardAnyTypeDefinition( (AnyType) type, isLazy() || isExtraLazy() );
}
};
}
@Override
public CollectionElementDefinition getElementDefinition() {
return new CollectionElementDefinition() {
@Override
public CollectionDefinition getCollectionDefinition() {
return AbstractCollectionPersister.this;
}
@Override
public Type getType() {
return getElementType();
}
@Override
public AnyMappingDefinition toAnyMappingDefinition() {
final Type type = getType();
if ( ! type.isAnyType() ) {
throw new IllegalStateException( "Cannot treat collection element type as ManyToAny" );
}
return new StandardAnyTypeDefinition( (AnyType) type, isLazy() || isExtraLazy() );
}
@Override
public EntityDefinition toEntityDefinition() {
if ( !getType().isEntityType() ) {
throw new IllegalStateException( "Cannot treat collection element type as entity" );
}
return getElementPersister();
}
@Override
public CompositeCollectionElementDefinition toCompositeElementDefinition() {
if ( ! getType().isComponentType() ) {
throw new IllegalStateException( "Cannot treat entity collection element type as composite" );
}
return new CompositeCollectionElementDefinition() {
@Override
public String getName() {
return "";
}
@Override
public CompositeType getType() {
return (CompositeType) getElementType();
}
@Override
public boolean isNullable() {
return false;
}
@Override
public AttributeSource getSource() {
// TODO: what if this is a collection w/in an encapsulated composition attribute?
// should return the encapsulated composition attribute instead???
return getOwnerEntityPersister();
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return CompositionSingularSubAttributesHelper.getCompositeCollectionElementSubAttributes( this );
}
@Override
public CollectionDefinition getCollectionDefinition() {
return AbstractCollectionPersister.this;
}
};
}
};
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// "mapping model"

View File

@ -30,7 +30,6 @@ import org.hibernate.metamodel.mapping.Restrictable;
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.walking.spi.CollectionDefinition;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.predicate.Predicate;
@ -86,7 +85,7 @@ import org.hibernate.type.Type;
*
* @author Gavin King
*/
public interface CollectionPersister extends CollectionDefinition, Restrictable {
public interface CollectionPersister extends Restrictable {
NavigableRole getNavigableRole();
/**

View File

@ -196,9 +196,6 @@ import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.internal.SqlFragmentPredicate;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.internal.EntityIdentifierDefinitionHelper;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.pretty.MessageHelper;
import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.property.access.spi.Setter;
@ -4056,7 +4053,6 @@ public abstract class AbstractEntityPersister
initPropertyPaths( mapping );
//doLateInit();
prepareEntityIdentifierDefinition();
}
private void doLateInit() {
@ -6526,17 +6522,6 @@ public abstract class AbstractEntityPersister
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// EntityDefinition impl (walking model - deprecated)
private EntityIdentifierDefinition entityIdentifierDefinition;
private final SortedSet<AttributeDefinition> attributeDefinitions = new TreeSet<>(
Comparator.comparing( AttributeDefinition::getName )
);
@Override
public void generateEntityDefinition() {
prepareEntityIdentifierDefinition();
collectAttributeDefinitions();
}
@Override
public int getJdbcTypeCount() {
return getIdentifierMapping().getJdbcTypeCount();
@ -6597,173 +6582,6 @@ public abstract class AbstractEntityPersister
);
}
@Override
public EntityIdentifierDefinition getEntityKeyDefinition() {
return entityIdentifierDefinition;
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return attributeDefinitions;
}
private void prepareEntityIdentifierDefinition() {
if ( entityIdentifierDefinition != null ) {
return;
}
final Type idType = getIdentifierType();
if ( !idType.isComponentType() ) {
entityIdentifierDefinition =
EntityIdentifierDefinitionHelper.buildSimpleEncapsulatedIdentifierDefinition( this );
return;
}
final CompositeType cidType = (CompositeType) idType;
if ( !cidType.isEmbedded() ) {
entityIdentifierDefinition =
EntityIdentifierDefinitionHelper.buildEncapsulatedCompositeIdentifierDefinition( this );
return;
}
entityIdentifierDefinition =
EntityIdentifierDefinitionHelper.buildNonEncapsulatedCompositeIdentifierDefinition( this );
}
private void collectAttributeDefinitions(
Map<String, AttributeDefinition> attributeDefinitionsByName,
EntityMetamodel metamodel) {
for ( int i = 0; i < metamodel.getPropertySpan(); i++ ) {
final AttributeDefinition attributeDefinition = metamodel.getProperties()[i];
// Don't replace an attribute definition if it is already in attributeDefinitionsByName
// because the new value will be from a subclass.
final AttributeDefinition oldAttributeDefinition = attributeDefinitionsByName.get(
attributeDefinition.getName()
);
if ( oldAttributeDefinition != null ) {
if ( LOG.isTraceEnabled() ) {
LOG.tracef(
"Ignoring subclass attribute definition [%s.%s] because it is defined in a superclass ",
entityMetamodel.getName(),
attributeDefinition.getName()
);
}
}
else {
attributeDefinitionsByName.put( attributeDefinition.getName(), attributeDefinition );
}
}
// see if there are any subclass persisters...
final Set<String> subClassEntityNames = metamodel.getSubclassEntityNames();
if ( subClassEntityNames == null ) {
return;
}
// see if we can find the persisters...
for ( String subClassEntityName : subClassEntityNames ) {
if ( metamodel.getName().equals( subClassEntityName ) ) {
// skip it
continue;
}
try {
final EntityPersister subClassEntityPersister = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( subClassEntityName );
collectAttributeDefinitions( attributeDefinitionsByName, subClassEntityPersister.getEntityMetamodel() );
}
catch (MappingException e) {
throw new IllegalStateException(
String.format(
"Could not locate subclass EntityPersister [%s] while processing EntityPersister [%s]",
subClassEntityName,
metamodel.getName()
),
e
);
}
}
}
private void collectAttributeDefinitions() {
// todo : I think this works purely based on luck atm
// specifically in terms of the sub/super class entity persister(s) being available. Bit of chicken-egg
// problem there:
// * If I do this during postConstruct (as it is now), it works as long as the
// super entity persister is already registered, but I don't think that is necessarily true.
// * If I do this during postInstantiate then lots of stuff in postConstruct breaks if we want
// to try and drive SQL generation on these (which we do ultimately). A possible solution there
// would be to delay all SQL generation until postInstantiate
Map<String, AttributeDefinition> attributeDefinitionsByName = new LinkedHashMap<>();
collectAttributeDefinitions( attributeDefinitionsByName, getEntityMetamodel() );
// EntityMetamodel currentEntityMetamodel = this.getEntityMetamodel();
// while ( currentEntityMetamodel != null ) {
// for ( int i = 0; i < currentEntityMetamodel.getPropertySpan(); i++ ) {
// attributeDefinitions.add( currentEntityMetamodel.getProperties()[i] );
// }
// // see if there is a super class EntityMetamodel
// final String superEntityName = currentEntityMetamodel.getSuperclass();
// if ( superEntityName != null ) {
// currentEntityMetamodel = factory.getEntityPersister( superEntityName ).getEntityMetamodel();
// }
// else {
// currentEntityMetamodel = null;
// }
// }
// // todo : leverage the attribute definitions housed on EntityMetamodel
// // for that to work, we'd have to be able to walk our super entity persister(s)
// this.attributeDefinitions = new Iterable<AttributeDefinition>() {
// @Override
// public Iterator<AttributeDefinition> iterator() {
// return new Iterator<AttributeDefinition>() {
//// private final int numberOfAttributes = countSubclassProperties();
//// private final int numberOfAttributes = entityMetamodel.getPropertySpan();
//
// EntityMetamodel currentEntityMetamodel = entityMetamodel;
// int numberOfAttributesInCurrentEntityMetamodel = currentEntityMetamodel.getPropertySpan();
//
// private int currentAttributeNumber;
//
// @Override
// public boolean hasNext() {
// return currentEntityMetamodel != null
// && currentAttributeNumber < numberOfAttributesInCurrentEntityMetamodel;
// }
//
// @Override
// public AttributeDefinition next() {
// final int attributeNumber = currentAttributeNumber;
// currentAttributeNumber++;
// final AttributeDefinition next = currentEntityMetamodel.getProperties()[ attributeNumber ];
//
// if ( currentAttributeNumber >= numberOfAttributesInCurrentEntityMetamodel ) {
// // see if there is a super class EntityMetamodel
// final String superEntityName = currentEntityMetamodel.getSuperclass();
// if ( superEntityName != null ) {
// currentEntityMetamodel = factory.getEntityPersister( superEntityName ).getEntityMetamodel();
// if ( currentEntityMetamodel != null ) {
// numberOfAttributesInCurrentEntityMetamodel = currentEntityMetamodel.getPropertySpan();
// currentAttributeNumber = 0;
// }
// }
// }
//
// return next;
// }
//
// @Override
// public void remove() {
// throw new UnsupportedOperationException( "Remove operation not supported here" );
// }
// };
// }
// };
}
protected Insert createInsert() {
return new Insert( getFactory().getJdbcServices().getDialect() );
}

View File

@ -38,7 +38,7 @@ import org.hibernate.metamodel.mapping.AttributeMapping;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.internal.InFlightEntityMappingType;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.sql.ast.spi.SqlAliasStemHelper;
@ -99,24 +99,13 @@ import org.hibernate.type.descriptor.java.VersionJavaType;
* @see org.hibernate.persister.spi.PersisterClassResolver
*/
public interface EntityPersister
extends EntityMappingType, Loadable, RootTableGroupProducer, EntityDefinition {
extends EntityMappingType, Loadable, RootTableGroupProducer, AttributeSource {
/**
* The property name of the "special" identifier property in HQL
*/
String ENTITY_ID = "id";
/**
* Generate the entity definition for this object. This must be done for all
* entity persisters before calling {@link #postInstantiate()}.
*
* @deprecated The legacy "walking model" is deprecated in favor of the newer "mapping model".
* This method is no longer called by Hibernate.
* See {@link InFlightEntityMappingType#prepareMappingModel} instead
*/
@Deprecated(since = "6.0")
void generateEntityDefinition();
/**
* Finish the initialization of this object. {@link InFlightEntityMappingType#prepareMappingModel}
* must be called for all entity persisters before calling this method.

View File

@ -1,298 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.internal;
import java.util.Iterator;
import org.hibernate.FetchMode;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.engine.spi.CascadeStyles;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.loader.PropertyPath;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.spi.HydratedCompoundValueHandler;
import org.hibernate.persister.walking.spi.AnyMappingDefinition;
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
import org.hibernate.persister.walking.spi.AssociationKey;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.persister.walking.spi.CollectionDefinition;
import org.hibernate.persister.walking.spi.CompositeCollectionElementDefinition;
import org.hibernate.persister.walking.spi.CompositionDefinition;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.persister.walking.spi.WalkingException;
import org.hibernate.sql.results.graph.FetchOptions;
import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType;
import org.hibernate.type.CompositeType;
import org.hibernate.type.Type;
/**
* A helper for getting attributes from a composition that is known
* to have only singular attributes; for example, sub-attributes of a
* composite ID or a composite collection element.
*
* TODO: This should be refactored into a delegate and renamed.
*
* @author Gail Badner
*/
public final class CompositionSingularSubAttributesHelper {
private CompositionSingularSubAttributesHelper() {
}
/**
* Get composite ID sub-attribute definitions.
*
* @param entityPersister - the entity persister.
*
* @return composite ID sub-attribute definitions.
*/
public static Iterable<AttributeDefinition> getIdentifierSubAttributes(AbstractEntityPersister entityPersister) {
return getSingularSubAttributes(
entityPersister,
entityPersister,
(CompositeType) entityPersister.getIdentifierType(),
entityPersister.getTableName(),
entityPersister.getRootTableIdentifierColumnNames()
);
}
/**
* Get sub-attribute definitions for a composite collection element.
* @param compositionElementDefinition - composite collection element definition.
* @return sub-attribute definitions for a composite collection element.
*/
public static Iterable<AttributeDefinition> getCompositeCollectionElementSubAttributes(
CompositeCollectionElementDefinition compositionElementDefinition) {
final QueryableCollection collectionPersister =
(QueryableCollection) compositionElementDefinition.getCollectionDefinition().getCollectionPersister();
return getSingularSubAttributes(
compositionElementDefinition.getSource(),
(OuterJoinLoadable) collectionPersister.getOwnerEntityPersister(),
(CompositeType) collectionPersister.getElementType(),
collectionPersister.getTableName(),
collectionPersister.getElementColumnNames()
);
}
public static Iterable<AttributeDefinition> getCompositeCollectionIndexSubAttributes(CompositeCollectionElementDefinition compositionElementDefinition){
final QueryableCollection collectionPersister =
(QueryableCollection) compositionElementDefinition.getCollectionDefinition().getCollectionPersister();
return getSingularSubAttributes(
compositionElementDefinition.getSource(),
(OuterJoinLoadable) collectionPersister.getOwnerEntityPersister(),
(CompositeType) collectionPersister.getIndexType(),
collectionPersister.getTableName(),
collectionPersister.toColumns( "index" )
);
}
private static Iterable<AttributeDefinition> getSingularSubAttributes(
final AttributeSource source,
final OuterJoinLoadable ownerEntityPersister,
final CompositeType compositeType,
final String lhsTableName,
final String[] lhsColumns) {
return new Iterable<AttributeDefinition>() {
@Override
public Iterator<AttributeDefinition> iterator() {
return new Iterator<AttributeDefinition>() {
private final int numberOfAttributes = compositeType.getSubtypes().length;
private int currentSubAttributeNumber;
private int currentColumnPosition;
@Override
public boolean hasNext() {
return currentSubAttributeNumber < numberOfAttributes;
}
@Override
public AttributeDefinition next() {
final int subAttributeNumber = currentSubAttributeNumber;
currentSubAttributeNumber++;
final String name = compositeType.getPropertyNames()[subAttributeNumber];
final Type type = compositeType.getSubtypes()[subAttributeNumber];
final FetchMode fetchMode = compositeType.getFetchMode( subAttributeNumber );
final int columnPosition = currentColumnPosition;
final int columnSpan = type.getColumnSpan( ownerEntityPersister.getFactory() );
final String[] subAttributeLhsColumns = ArrayHelper.slice( lhsColumns, columnPosition, columnSpan );
final boolean[] propertyNullability = compositeType.getPropertyNullability();
final boolean nullable = propertyNullability == null || propertyNullability[subAttributeNumber];
currentColumnPosition += columnSpan;
if ( type.isAssociationType() ) {
final AssociationType aType = (AssociationType) type;
return new AssociationAttributeDefinition() {
@Override
public AssociationKey getAssociationKey() {
return new AssociationKey( lhsTableName, subAttributeLhsColumns );
}
@Override
public AssociationNature getAssociationNature() {
if ( type.isAnyType() ) {
return AssociationNature.ANY;
}
else {
// cannot be a collection
return AssociationNature.ENTITY;
}
}
@Override
public EntityDefinition toEntityDefinition() {
if ( getAssociationNature() != AssociationNature.ENTITY ) {
throw new WalkingException(
"Cannot build EntityDefinition from non-entity-typed attribute"
);
}
return (EntityPersister) aType.getAssociatedJoinable( ownerEntityPersister.getFactory() );
}
@Override
public AnyMappingDefinition toAnyDefinition() {
if ( getAssociationNature() != AssociationNature.ANY ) {
throw new WalkingException(
"Cannot build AnyMappingDefinition from non-any-typed attribute"
);
}
// todo : not sure how lazy is propagated into the component for a sub-attribute of type any
return new StandardAnyTypeDefinition( (AnyType) aType, false );
}
@Override
public CollectionDefinition toCollectionDefinition() {
throw new WalkingException( "A collection cannot be mapped to a composite ID sub-attribute." );
}
@Override
public FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
final FetchStyle style = FetchOptionsHelper.determineFetchStyleByMetadata(
fetchMode,
(AssociationType) type,
ownerEntityPersister.getFactory()
);
final FetchTiming timing = FetchOptionsHelper.determineFetchTiming(
style,
getType(),
ownerEntityPersister.getFactory()
);
return FetchOptions.valueOf( timing, style );
}
@Override
public CascadeStyle determineCascadeStyle() {
return CascadeStyles.NONE;
}
@Override
public HydratedCompoundValueHandler getHydratedCompoundValueExtractor() {
return null;
}
@Override
public String getName() {
return name;
}
@Override
public AssociationType getType() {
return aType;
}
@Override
public boolean isNullable() {
return nullable;
}
@Override
public AttributeSource getSource() {
return source;
}
};
}
else if ( type.isComponentType() ) {
return new CompositionDefinition() {
@Override
public String getName() {
return name;
}
@Override
public CompositeType getType() {
return (CompositeType) type;
}
@Override
public boolean isNullable() {
return nullable;
}
@Override
public AttributeSource getSource() {
return source;
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return CompositionSingularSubAttributesHelper.getSingularSubAttributes(
this,
ownerEntityPersister,
(CompositeType) type,
lhsTableName,
subAttributeLhsColumns
);
}
};
}
else {
return new AttributeDefinition() {
@Override
public String getName() {
return name;
}
@Override
public Type getType() {
return type;
}
@Override
public boolean isNullable() {
return nullable;
}
@Override
public AttributeSource getSource() {
return source;
}
};
}
}
@Override
public void remove() {
throw new UnsupportedOperationException( "Remove operation not supported here" );
}
};
}
};
}
}

View File

@ -1,183 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.internal;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.persister.walking.spi.CompositionDefinition;
import org.hibernate.persister.walking.spi.EncapsulatedEntityIdentifierDefinition;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.persister.walking.spi.NonEncapsulatedEntityIdentifierDefinition;
import org.hibernate.type.CompositeType;
import org.hibernate.type.Type;
/**
* @author Gail Badner
*/
public final class EntityIdentifierDefinitionHelper {
private EntityIdentifierDefinitionHelper() {
}
public static EntityIdentifierDefinition buildSimpleEncapsulatedIdentifierDefinition(final EntityPersister entityPersister) {
return new EncapsulatedEntityIdentifierDefinition() {
private final AttributeDefinitionAdapter attr = new AttributeDefinitionAdapter( entityPersister);
@Override
public AttributeDefinition getAttributeDefinition() {
return attr;
}
@Override
public boolean isEncapsulated() {
return true;
}
@Override
public EntityDefinition getEntityDefinition() {
return entityPersister;
}
};
}
public static EntityIdentifierDefinition buildEncapsulatedCompositeIdentifierDefinition(
final AbstractEntityPersister entityPersister) {
return new EncapsulatedEntityIdentifierDefinition() {
private final CompositionDefinitionAdapter compositionDefinition = new CompositionDefinitionAdapter( entityPersister );
@Override
public AttributeDefinition getAttributeDefinition() {
return compositionDefinition;
}
@Override
public boolean isEncapsulated() {
return true;
}
@Override
public EntityDefinition getEntityDefinition() {
return entityPersister;
}
};
}
public static EntityIdentifierDefinition buildNonEncapsulatedCompositeIdentifierDefinition(final AbstractEntityPersister entityPersister) {
return new NonEncapsulatedEntityIdentifierDefinition() {
private final CompositionDefinitionAdapter compositionDefinition = new CompositionDefinitionAdapter( entityPersister );
@Override
public Iterable<AttributeDefinition> getAttributes() {
return compositionDefinition.getAttributes();
}
@Override
public Class getSeparateIdentifierMappingClass() {
return entityPersister.getEntityMetamodel().getIdentifierProperty().hasIdentifierMapper() ?
entityPersister.getEntityMetamodel().getIdentifierProperty().getType().getReturnedClass() :
null;
}
@Override
public boolean isEncapsulated() {
return false;
}
@Override
public EntityDefinition getEntityDefinition() {
return entityPersister;
}
@Override
public Type getCompositeType() {
return entityPersister.getEntityMetamodel().getIdentifierProperty().getType();
}
@Override
public AttributeSource getSource() {
return compositionDefinition;
}
@Override
public String getName() {
// Not sure this is always kosher. See org.hibernate.tuple.entity.EntityMetamodel.hasNonIdentifierPropertyNamedId
return "id";
}
@Override
public CompositeType getType() {
return (CompositeType) getCompositeType();
}
@Override
public boolean isNullable() {
return compositionDefinition.isNullable();
}
};
}
private static class AttributeDefinitionAdapter implements AttributeDefinition {
private final EntityPersister entityPersister;
AttributeDefinitionAdapter(EntityPersister entityPersister) {
this.entityPersister = entityPersister;
}
@Override
public String getName() {
return entityPersister.getEntityMetamodel().getIdentifierProperty().getName();
}
@Override
public Type getType() {
return entityPersister.getEntityMetamodel().getIdentifierProperty().getType();
}
@Override
public boolean isNullable() {
return false;
}
@Override
public AttributeSource getSource() {
return entityPersister;
}
@Override
public String toString() {
return "<identifier-property:" + getName() + ">";
}
protected EntityPersister getEntityPersister() {
return entityPersister;
}
}
private static class CompositionDefinitionAdapter extends AttributeDefinitionAdapter implements CompositionDefinition {
CompositionDefinitionAdapter(AbstractEntityPersister entityPersister) {
super( entityPersister );
}
@Override
public String toString() {
return "<identifier-property:" + getName() + ">";
}
@Override
public CompositeType getType() {
return (CompositeType) super.getType();
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return CompositionSingularSubAttributesHelper.getIdentifierSubAttributes( (AbstractEntityPersister) getEntityPersister() );
}
}
}

View File

@ -1,86 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.internal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.hibernate.persister.walking.spi.AnyMappingDefinition;
import org.hibernate.type.AnyType;
import org.hibernate.type.MetaType;
import org.hibernate.type.Type;
/**
* @author Steve Ebersole
*/
public class StandardAnyTypeDefinition implements AnyMappingDefinition {
private final AnyType anyType;
private final boolean definedAsLazy;
private final List<DiscriminatorMapping> discriminatorMappings;
public StandardAnyTypeDefinition(AnyType anyType, boolean definedAsLazy) {
this.anyType = anyType;
this.definedAsLazy = definedAsLazy;
this.discriminatorMappings = interpretDiscriminatorMappings( anyType );
}
private static List<DiscriminatorMapping> interpretDiscriminatorMappings(AnyType anyType) {
final Type discriminatorType = anyType.getDiscriminatorType();
if ( !(discriminatorType instanceof MetaType) ) {
return Collections.emptyList();
}
final MetaType metaType = (MetaType) discriminatorType;
final List<DiscriminatorMapping> discriminatorMappings = new ArrayList<>();
for ( final Map.Entry<Object,String> entry : metaType.getDiscriminatorValuesToEntityNameMap().entrySet() ) {
discriminatorMappings.add(
new DiscriminatorMapping() {
private final Object discriminatorValue = entry.getKey();
private final String entityName = entry.getValue();
@Override
public Object getDiscriminatorValue() {
return discriminatorValue;
}
@Override
public String getEntityName() {
return entityName;
}
}
);
}
return discriminatorMappings;
}
@Override
public AnyType getType() {
return anyType;
}
@Override
public boolean isLazy() {
return definedAsLazy;
}
@Override
public Type getIdentifierType() {
return anyType.getIdentifierType();
}
@Override
public Type getDiscriminatorType() {
return anyType.getDiscriminatorType();
}
@Override
public Iterable<DiscriminatorMapping> getMappingDefinedDiscriminatorMappings() {
return discriminatorMappings;
}
}

View File

@ -1,87 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.type.AnyType;
import org.hibernate.type.Type;
/**
* Describes an ANY mapping
*
* @author Steve Ebersole
*/
public interface AnyMappingDefinition {
/**
* Access to the mapping's AnyType
*
* @return The AnyType
*/
AnyType getType();
/**
* Was the mapping defined as lazy?
*
* @return true/false
*/
boolean isLazy();
/**
* Access to the type of the value that makes up the identifier portion of the AnyType.
*
* @return The identifier type
*/
Type getIdentifierType();
/**
* Access to the type of the value that makes up the discriminator portion of the AnyType. The discriminator is
* historically called the "meta".
* <p/>
* NOTE : If explicit discriminator mappings are given, the type here will be a {@link org.hibernate.type.MetaType}.
*
* @return The discriminator type
*/
Type getDiscriminatorType();
/**
* Access to discriminator mappings explicitly defined in the mapping metadata.
*
* There are 2 flavors of discrimination:<ol>
* <li>
* The database holds the concrete entity names. This is an implicit form, meaning that the discriminator
* mappings do not have to be defined in the mapping metadata. In this case, an empty iterable is returned
* here
* </li>
* <li>
* The database holds discriminator values that are interpreted to corresponding entity names based on
* discriminator mappings explicitly supplied in the mapping metadata. In this case, this method gives access
* to those explicitly defined mappings.
* </li>
* </ol>
*
* @return The explicitly defined discriminator value mappings.
*/
Iterable<DiscriminatorMapping> getMappingDefinedDiscriminatorMappings();
/**
* Models a single discriminator mapping definition
*/
interface DiscriminatorMapping {
/**
* Access to the defined discriminator value (the database value) being mapped.
*
* @return The defined discriminator value
*/
Object getDiscriminatorValue();
/**
* Access to the defined entity name corresponding to the defined {@link #getDiscriminatorValue()}
*
* @return The defined entity name
*/
String getEntityName();
}
}

View File

@ -1,44 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.loader.PropertyPath;
import org.hibernate.persister.spi.HydratedCompoundValueHandler;
import org.hibernate.sql.results.graph.FetchOptions;
import org.hibernate.type.AssociationType;
/**
* @author Steve Ebersole
*/
public interface AssociationAttributeDefinition extends AttributeDefinition {
@Override
AssociationType getType();
AssociationKey getAssociationKey();
enum AssociationNature {
ANY,
ENTITY,
COLLECTION
}
AssociationNature getAssociationNature();
EntityDefinition toEntityDefinition();
CollectionDefinition toCollectionDefinition();
AnyMappingDefinition toAnyDefinition();
FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath);
CascadeStyle determineCascadeStyle();
HydratedCompoundValueHandler getHydratedCompoundValueExtractor();
}

View File

@ -1,69 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import java.util.Arrays;
/**
* Used to uniquely identify a foreign key, so that we don't join it more than once creating circularities. Note
* that the table+columns refers to the association owner. These are used to help detect bi-directional associations
* since the Hibernate runtime metamodel (persisters) do not inherently know this information. For example, consider
* the Order -> Customer and Customer -> Order(s) bi-directional association; both would be mapped to the
* {@code ORDER_TABLE.CUST_ID} column. That is the purpose of this struct.
* <p/>
* Bit of a misnomer to call this an association attribute. But this follows the legacy use of AssociationKey
* from old JoinWalkers to denote circular join detection
*
* @author Steve Ebersole
* @author Gail Badner
* @author Gavin King
*/
public class AssociationKey {
private final String table;
private final String[] columns;
/**
* Create the AssociationKey.
*
* @param table The table part of the association key
* @param columns The columns that define the association key
*/
public AssociationKey(String table, String[] columns) {
this.table = table;
this.columns = columns;
}
@Override
public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( o == null || getClass() != o.getClass() ) {
return false;
}
final AssociationKey that = (AssociationKey) o;
return table.equals( that.table ) && Arrays.equals( columns, that.columns );
}
@Override
public int hashCode() {
return table.hashCode();
}
private String str;
@Override
public String toString() {
if ( str == null ) {
str = "AssociationKey(table=" + table + ", columns={" + String.join( ",", columns ) + "})";
}
return str;
}
}

View File

@ -1,20 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.type.Type;
/**
* Descriptor for
* @author Steve Ebersole
*/
public interface AttributeDefinition {
AttributeSource getSource();
String getName();
Type getType();
boolean isNullable();
}

View File

@ -10,5 +10,4 @@ package org.hibernate.persister.walking.spi;
* @author Steve Ebersole
*/
public interface AttributeSource {
Iterable<AttributeDefinition> getAttributes();
}

View File

@ -1,21 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.type.CollectionType;
/**
* @author Steve Ebersole
*/
public interface CollectionDefinition {
CollectionPersister getCollectionPersister();
CollectionType getCollectionType();
CollectionIndexDefinition getIndexDefinition();
CollectionElementDefinition getElementDefinition();
}

View File

@ -1,71 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.type.Type;
/**
* Represents a collection element.
*
* @author Steve Ebersole
*/
public interface CollectionElementDefinition {
/**
* Returns the collection definition.
* @return the collection definition.
*/
CollectionDefinition getCollectionDefinition();
/**
* Returns the collection element type.
* @return the collection element type
*/
Type getType();
/**
* If the element type returned by {@link #getType()} is an
* {@link org.hibernate.type.AnyType}, then the any mapping
* definition for the collection element is returned;
* otherwise, IllegalStateException is thrown.
*
* @return the any mapping definition for the collection element.
*
* @throws IllegalStateException if the collection element type
* returned by {@link #getType()} is not of type
* {@link org.hibernate.type.AnyType}.
*/
AnyMappingDefinition toAnyMappingDefinition();
/**
* If the element type returned by {@link #getType()} is an
* {@link org.hibernate.type.EntityType}, then the entity
* definition for the collection element is returned;
* otherwise, IllegalStateException is thrown.
*
* @return the entity definition for the collection element.
*
* @throws IllegalStateException if the collection element type
* returned by {@link #getType()} is not of type
* {@link org.hibernate.type.EntityType}.
*/
EntityDefinition toEntityDefinition();
/**
* If the element type returned by {@link #getType()} is a
* {@link org.hibernate.type.CompositeType}, then the composite
* element definition for the collection element is returned;
* otherwise, IllegalStateException is thrown.
*
* @return the composite element definition for the collection element.
*
* @throws IllegalStateException if the collection element type
* returned by {@link #getType()} is not of type
* {@link org.hibernate.type.CompositeType}.
*/
CompositeCollectionElementDefinition toCompositeElementDefinition();
}

View File

@ -1,65 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.type.Type;
/**
* @author Steve Ebersole
*/
public interface CollectionIndexDefinition {
/**
* Returns the collection definition.
* @return the collection definition.
*/
CollectionDefinition getCollectionDefinition();
/**
* Returns the collection index type.
* @return the collection index type
*/
Type getType();
/**
* If the index type returned by {@link #getType()} is an
* {@link org.hibernate.type.EntityType}, then the entity
* definition for the collection index is returned;
* otherwise, IllegalStateException is thrown.
*
* @return the entity definition for the collection index.
*
* @throws IllegalStateException if the collection index type
* returned by {@link #getType()} is not of type
* {@link org.hibernate.type.EntityType}.
*/
EntityDefinition toEntityDefinition();
/**
* If the index type returned by {@link #getType()} is a
* {@link org.hibernate.type.CompositeType}, then the composite
* index definition for the collection index is returned;
* otherwise, IllegalStateException is thrown.
*
* @return the composite index definition for the collection index.
*
* @throws IllegalStateException if the collection index type
* returned by {@link #getType()} is not of type
* {@link org.hibernate.type.CompositeType}.
*/
CompositionDefinition toCompositeDefinition();
/**
* If the index type returned by {@link #getType()} is an
* {@link org.hibernate.type.AnyType}, then the any mapping
* definition for the collection index is returned;
* otherwise, IllegalStateException is thrown.
*
* @return the any mapping definition for the collection index.
*
* @throws IllegalStateException if the collection index type
* returned by {@link #getType()} is not of type
* {@link org.hibernate.type.AnyType}.
*/
AnyMappingDefinition toAnyMappingDefinition();
}

View File

@ -1,20 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
/**
* The definition for a composite collection element.
*
* @author Gail Badner
*/
public interface CompositeCollectionElementDefinition extends CompositionDefinition{
/**
* Returns the collection definition.
* @return the collection definition.
*/
CollectionDefinition getCollectionDefinition();
}

View File

@ -1,17 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.type.CompositeType;
/**
* @author Steve Ebersole
*/
public interface CompositionDefinition extends AttributeDefinition, AttributeSource {
@Override
CompositeType getType();
}

View File

@ -1,14 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
/**
* @author Steve Ebersole
*/
public interface EncapsulatedEntityIdentifierDefinition extends EntityIdentifierDefinition {
AttributeDefinition getAttributeDefinition();
}

View File

@ -1,19 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.persister.entity.EntityPersister;
/**
* Defines the contract for walking the attributes defined by an entity
*
* @author Steve Ebersole
*/
public interface EntityDefinition extends AttributeSource {
EntityPersister getEntityPersister();
EntityIdentifierDefinition getEntityKeyDefinition();
}

View File

@ -1,26 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
/**
* Describes aspects of the identifier for an entity
*
* @author Steve Ebersole
*/
public interface EntityIdentifierDefinition {
/**
* Is the entity identifier encapsulated? Meaning, is it represented by a single attribute?
*
* @return {@code true} indicates the identifier is encapsulated (and therefore this is castable to
* {@link EncapsulatedEntityIdentifierDefinition}); {@code false} means it is not encapsulated (and therefore
* castable to {@link NonEncapsulatedEntityIdentifierDefinition}).
*
*/
boolean isEncapsulated();
EntityDefinition getEntityDefinition();
}

View File

@ -1,19 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.type.Type;
/**
* @author Steve Ebersole
*/
public interface NonEncapsulatedEntityIdentifierDefinition extends EntityIdentifierDefinition, CompositionDefinition {
Type getCompositeType();
Class getSeparateIdentifierMappingClass();
}

View File

@ -1,24 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.walking.spi;
import org.hibernate.HibernateError;
/**
* Indicates a problem walking the domain tree. Almost always this indicates an internal error in Hibernate
*
* @author Steve Ebersole
*/
public class WalkingException extends HibernateError {
public WalkingException(String message) {
super( message );
}
public WalkingException(String message, Throwable root) {
super( message, root );
}
}

View File

@ -37,7 +37,6 @@ public abstract class AbstractNonIdentifierAttribute extends AbstractAttribute i
this.attributeInformation = attributeInformation;
}
@Override
public AttributeSource getSource() {
return source();
}

View File

@ -8,12 +8,11 @@ package org.hibernate.tuple;
import org.hibernate.FetchMode;
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.persister.walking.spi.AttributeDefinition;
/**
* @author Steve Ebersole
*/
public interface NonIdentifierAttribute extends Attribute, AttributeDefinition {
public interface NonIdentifierAttribute extends Attribute {
boolean isLazy();
boolean isInsertable();

View File

@ -286,40 +286,4 @@ public final class PropertyFactory {
);
}
private static Constructor<?> getConstructor(PersistentClass persistentClass) {
if ( persistentClass == null || !persistentClass.hasPojoRepresentation() ) {
return null;
}
try {
return ReflectHelper.getDefaultConstructor( persistentClass.getMappedClass() );
}
catch (Throwable t) {
return null;
}
}
private static Getter getGetter(Property mappingProperty) {
if ( mappingProperty == null || !mappingProperty.getPersistentClass().hasPojoRepresentation() ) {
return null;
}
final PropertyAccessStrategyResolver propertyAccessStrategyResolver =
mappingProperty.getPersistentClass().getServiceRegistry().getService( PropertyAccessStrategyResolver.class );
final PropertyAccessStrategy propertyAccessStrategy = propertyAccessStrategyResolver.resolvePropertyAccessStrategy(
mappingProperty.getClass(),
mappingProperty.getPropertyAccessorName(),
RepresentationMode.POJO
);
final PropertyAccess propertyAccess = propertyAccessStrategy.buildPropertyAccess(
mappingProperty.getPersistentClass().getMappedClass(),
mappingProperty.getName(),
true );
return propertyAccess.getGetter();
}
}

View File

@ -6,28 +6,12 @@
*/
package org.hibernate.tuple.component;
import java.util.Iterator;
import org.hibernate.engine.internal.JoinHelper;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.walking.spi.AssociationKey;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.persister.walking.spi.CompositionDefinition;
import org.hibernate.tuple.AbstractNonIdentifierAttribute;
import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.AssociationType;
import org.hibernate.type.CompositeType;
import org.hibernate.type.ForeignKeyDirection;
import org.hibernate.type.Type;
import static org.hibernate.engine.internal.JoinHelper.getLHSColumnNames;
import static org.hibernate.engine.internal.JoinHelper.getLHSTableName;
import static org.hibernate.engine.internal.JoinHelper.getRHSColumnNames;
/**
* A base class for a composite, non-identifier attribute.
@ -36,7 +20,7 @@ import static org.hibernate.engine.internal.JoinHelper.getRHSColumnNames;
*/
public abstract class AbstractCompositionAttribute
extends AbstractNonIdentifierAttribute
implements CompositionDefinition {
implements AttributeSource {
private final int columnStartPosition;
@ -57,159 +41,6 @@ public abstract class AbstractCompositionAttribute
return (CompositeType) super.getType();
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return () -> new Iterator<>() {
private final int numberOfAttributes = getType().getSubtypes().length;
private int currentSubAttributeNumber;
private int currentColumnPosition = columnStartPosition;
@Override
public boolean hasNext() {
return currentSubAttributeNumber < numberOfAttributes;
}
@Override
public AttributeDefinition next() {
final int subAttributeNumber = currentSubAttributeNumber;
currentSubAttributeNumber++;
final String name = getType().getPropertyNames()[subAttributeNumber];
final Type type = getType().getSubtypes()[subAttributeNumber];
int columnPosition = currentColumnPosition;
currentColumnPosition += type.getColumnSpan( sessionFactory() );
final CompositeType cType = getType();
final boolean nullable =
cType.getPropertyNullability() == null ||
cType.getPropertyNullability()[subAttributeNumber];
if ( type.isAssociationType() ) {
// we build the association-key here because of the "goofiness" with 'currentColumnPosition'
final AssociationKey associationKey;
final AssociationType aType = (AssociationType) type;
if ( aType.isAnyType() ) {
associationKey = new AssociationKey(
JoinHelper.getLHSTableName(
aType,
attributeNumber(),
(OuterJoinLoadable) locateOwningPersister()
),
JoinHelper.getLHSColumnNames(
aType,
attributeNumber(),
columnPosition,
(OuterJoinLoadable) locateOwningPersister(),
sessionFactory()
)
);
}
else if ( aType.getForeignKeyDirection() == ForeignKeyDirection.FROM_PARENT ) {
final Joinable joinable = aType.getAssociatedJoinable( sessionFactory() );
final String lhsTableName;
final String[] lhsColumnNames;
if ( joinable.isCollection() ) {
final QueryableCollection collectionPersister = (QueryableCollection) joinable;
lhsTableName = collectionPersister.getTableName();
lhsColumnNames = collectionPersister.getElementColumnNames();
}
else {
final OuterJoinLoadable entityPersister = (OuterJoinLoadable) locateOwningPersister();
lhsTableName = getLHSTableName( aType, attributeNumber(), entityPersister );
lhsColumnNames = getLHSColumnNames(
aType,
attributeNumber(),
columnPosition,
entityPersister,
sessionFactory()
);
}
associationKey = new AssociationKey( lhsTableName, lhsColumnNames );
}
else {
final Joinable joinable = aType.getAssociatedJoinable( sessionFactory() );
associationKey = new AssociationKey(
joinable.getTableName(),
getRHSColumnNames( aType, sessionFactory() )
);
}
return new CompositeBasedAssociationAttribute(
AbstractCompositionAttribute.this,
sessionFactory(),
attributeNumber(),
name,
(AssociationType) type,
new BaselineAttributeInformation.Builder()
.setInsertable( AbstractCompositionAttribute.this.isInsertable() )
.setUpdateable( AbstractCompositionAttribute.this.isUpdateable() )
// todo : handle nested ValueGeneration strategies...
// disallow if our strategy != NEVER
.setNullable( nullable )
.setDirtyCheckable( true )
.setVersionable( AbstractCompositionAttribute.this.isVersionable() )
.setCascadeStyle( getType().getCascadeStyle( subAttributeNumber ) )
.setFetchMode( getType().getFetchMode( subAttributeNumber ) )
.createInformation(),
subAttributeNumber,
associationKey
);
}
else if ( type.isComponentType() ) {
return new CompositionBasedCompositionAttribute(
AbstractCompositionAttribute.this,
sessionFactory(),
attributeNumber(),
name,
(CompositeType) type,
columnPosition,
new BaselineAttributeInformation.Builder()
.setInsertable( AbstractCompositionAttribute.this.isInsertable() )
.setUpdateable( AbstractCompositionAttribute.this.isUpdateable() )
// todo : handle nested ValueGeneration strategies...
// disallow if our strategy != NEVER
.setNullable( nullable )
.setDirtyCheckable( true )
.setVersionable( AbstractCompositionAttribute.this.isVersionable() )
.setCascadeStyle( getType().getCascadeStyle( subAttributeNumber ) )
.setFetchMode( getType().getFetchMode( subAttributeNumber ) )
.createInformation()
);
}
else {
return new CompositeBasedBasicAttribute(
AbstractCompositionAttribute.this,
sessionFactory(),
subAttributeNumber,
name,
type,
new BaselineAttributeInformation.Builder()
.setInsertable( AbstractCompositionAttribute.this.isInsertable() )
.setUpdateable( AbstractCompositionAttribute.this.isUpdateable() )
// todo : handle nested ValueGeneration strategies...
// disallow if our strategy != NEVER
.setNullable( nullable )
.setDirtyCheckable( true )
.setVersionable( AbstractCompositionAttribute.this.isVersionable() )
.setCascadeStyle( getType().getCascadeStyle( subAttributeNumber ) )
.setFetchMode( getType().getFetchMode( subAttributeNumber ) )
.createInformation()
);
}
}
@Override
public void remove() {
throw new UnsupportedOperationException( "Remove operation not supported here" );
}
};
}
protected abstract EntityPersister locateOwningPersister();
@Override

View File

@ -1,194 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tuple.component;
import org.hibernate.FetchMode;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.loader.PropertyPath;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.spi.HydratedCompoundValueHandler;
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
import org.hibernate.persister.walking.internal.StandardAnyTypeDefinition;
import org.hibernate.persister.walking.spi.AnyMappingDefinition;
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
import org.hibernate.persister.walking.spi.AssociationKey;
import org.hibernate.persister.walking.spi.CollectionDefinition;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.persister.walking.spi.WalkingException;
import org.hibernate.sql.results.graph.FetchOptions;
import org.hibernate.tuple.AbstractNonIdentifierAttribute;
import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.tuple.NonIdentifierAttribute;
import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType;
/**
* @author Steve Ebersole
*/
public class CompositeBasedAssociationAttribute
extends AbstractNonIdentifierAttribute
implements NonIdentifierAttribute, AssociationAttributeDefinition {
private final int subAttributeNumber;
private final AssociationKey associationKey;
private Joinable joinable;
public CompositeBasedAssociationAttribute(
AbstractCompositionAttribute source,
SessionFactoryImplementor factory,
int entityBasedAttributeNumber,
String attributeName,
AssociationType attributeType,
BaselineAttributeInformation baselineInfo,
int subAttributeNumber,
AssociationKey associationKey) {
super( source, factory, entityBasedAttributeNumber, attributeName, attributeType, baselineInfo );
this.subAttributeNumber = subAttributeNumber;
this.associationKey = associationKey;
}
@Override
public AssociationType getType() {
return (AssociationType) super.getType();
}
@Override
public AbstractCompositionAttribute getSource() {
return (AbstractCompositionAttribute) super.getSource();
}
protected Joinable getJoinable() {
if ( joinable == null ) {
joinable = getType().getAssociatedJoinable( sessionFactory() );
}
return joinable;
}
@Override
public AssociationKey getAssociationKey() {
return associationKey;
}
@Override
public AssociationNature getAssociationNature() {
if ( getType().isAnyType() ) {
return AssociationNature.ANY;
}
else {
if ( getJoinable().isCollection() ) {
return AssociationNature.COLLECTION;
}
else {
return AssociationNature.ENTITY;
}
}
}
private boolean isAnyType() {
return getAssociationNature() == AssociationNature.ANY;
}
private boolean isEntityType() {
return getAssociationNature() == AssociationNature.ENTITY;
}
private boolean isCollection() {
return getAssociationNature() == AssociationNature.COLLECTION;
}
@Override
public AnyMappingDefinition toAnyDefinition() {
if ( !isAnyType() ) {
throw new WalkingException( "Cannot build AnyMappingDefinition from non-any-typed attribute" );
}
// todo : not sure how lazy is propogated into the component for a subattribute of type any
return new StandardAnyTypeDefinition( (AnyType) getType(), false );
}
@Override
public EntityDefinition toEntityDefinition() {
if ( isCollection() ) {
throw new IllegalStateException( "Cannot treat collection attribute as entity type" );
}
if ( isAnyType() ) {
throw new IllegalStateException( "Cannot treat any-type attribute as entity type" );
}
return (EntityPersister) getJoinable();
}
@Override
public CollectionDefinition toCollectionDefinition() {
if ( isEntityType() ) {
throw new IllegalStateException( "Cannot treat entity attribute as collection type" );
}
if ( isAnyType() ) {
throw new IllegalStateException( "Cannot treat any-type attribute as collection type" );
}
return (CollectionPersister) getJoinable();
}
@Override
public FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
final EntityPersister owningPersister = getSource().locateOwningPersister();
FetchStyle style = FetchOptionsHelper.determineFetchStyleByProfile(
loadQueryInfluencers,
owningPersister,
propertyPath,
attributeNumber()
);
if ( style == null ) {
style = determineFetchStyleByMetadata( getFetchMode(), getType() );
}
return FetchOptions.valueOf( determineFetchTiming( style ), style );
}
protected FetchStyle determineFetchStyleByMetadata(FetchMode fetchMode, AssociationType type) {
return FetchOptionsHelper.determineFetchStyleByMetadata( fetchMode, type, sessionFactory() );
}
private FetchTiming determineFetchTiming(FetchStyle style) {
return FetchOptionsHelper.determineFetchTiming( style, getType(), sessionFactory() );
}
@Override
public CascadeStyle determineCascadeStyle() {
return getCascadeStyle();
}
private HydratedCompoundValueHandler hydratedCompoundValueHandler;
@Override
public HydratedCompoundValueHandler getHydratedCompoundValueExtractor() {
if ( hydratedCompoundValueHandler == null ) {
hydratedCompoundValueHandler = new HydratedCompoundValueHandler() {
@Override
public Object extract(Object hydratedState) {
return ( (Object[] ) hydratedState )[ subAttributeNumber ];
}
@Override
public void inject(Object hydratedState, Object value) {
( (Object[] ) hydratedState )[ subAttributeNumber ] = value;
}
};
}
return hydratedCompoundValueHandler;
}
@Override
protected String loggableMetadata() {
return super.loggableMetadata() + ",association";
}
}

View File

@ -1,28 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tuple.component;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.tuple.AbstractNonIdentifierAttribute;
import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.Type;
/**
* @author Steve Ebersole
*/
public class CompositeBasedBasicAttribute extends AbstractNonIdentifierAttribute {
protected CompositeBasedBasicAttribute(
AttributeSource source,
SessionFactoryImplementor sessionFactory,
int attributeNumber,
String attributeName,
Type attributeType,
BaselineAttributeInformation baselineInfo) {
super( source, sessionFactory, attributeNumber, attributeName, attributeType, baselineInfo );
}
}

View File

@ -1,49 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.tuple.component;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.CompositeType;
/**
* @author Steve Ebersole
*/
public class CompositionBasedCompositionAttribute extends AbstractCompositionAttribute {
public CompositionBasedCompositionAttribute(
AbstractCompositionAttribute source,
SessionFactoryImplementor sessionFactory,
int entityBasedAttributeNumber,
String attributeName,
CompositeType attributeType,
int columnStartPosition,
BaselineAttributeInformation baselineInfo) {
super(
source,
sessionFactory,
entityBasedAttributeNumber,
attributeName,
attributeType,
columnStartPosition,
baselineInfo
);
}
@Override
protected EntityPersister locateOwningPersister() {
final AbstractCompositionAttribute source = (AbstractCompositionAttribute) getSource();
if (source.getSource() instanceof EntityDefinition) {
return ( (EntityDefinition) source.getSource() ).getEntityPersister();
}
else {
return ( (AbstractCompositionAttribute) source.getSource() ).locateOwningPersister();
}
}
}

View File

@ -6,42 +6,16 @@
*/
package org.hibernate.tuple.entity;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.internal.JoinHelper;
import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.loader.PropertyPath;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.spi.HydratedCompoundValueHandler;
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
import org.hibernate.persister.walking.internal.StandardAnyTypeDefinition;
import org.hibernate.persister.walking.spi.AnyMappingDefinition;
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
import org.hibernate.persister.walking.spi.AssociationKey;
import org.hibernate.persister.walking.spi.CollectionDefinition;
import org.hibernate.persister.walking.spi.EntityDefinition;
import org.hibernate.persister.walking.spi.WalkingException;
import org.hibernate.sql.results.graph.FetchOptions;
import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.type.AnyType;
import org.hibernate.type.AssociationType;
import org.hibernate.type.ForeignKeyDirection;
import static org.hibernate.engine.internal.JoinHelper.getLHSColumnNames;
import static org.hibernate.engine.internal.JoinHelper.getLHSTableName;
import static org.hibernate.engine.internal.JoinHelper.getRHSColumnNames;
/**
* @author Steve Ebersole
*/
public class EntityBasedAssociationAttribute
extends AbstractEntityBasedAttribute
implements AssociationAttributeDefinition {
extends AbstractEntityBasedAttribute {
public EntityBasedAssociationAttribute(
@ -58,151 +32,6 @@ public class EntityBasedAssociationAttribute
public AssociationType getType() {
return (AssociationType) super.getType();
}
@Override
public AssociationKey getAssociationKey() {
final AssociationType type = getType();
if ( type.isAnyType() ) {
return new AssociationKey(
JoinHelper.getLHSTableName( type, attributeNumber(), (OuterJoinLoadable) getSource() ),
JoinHelper.getLHSColumnNames(
type,
attributeNumber(),
0,
(OuterJoinLoadable) getSource(),
sessionFactory()
)
);
}
final Joinable joinable = type.getAssociatedJoinable( sessionFactory() );
if ( type.getForeignKeyDirection() == ForeignKeyDirection.FROM_PARENT ) {
final String lhsTableName;
final String[] lhsColumnNames;
if ( joinable.isCollection() ) {
final QueryableCollection collectionPersister = (QueryableCollection) joinable;
lhsTableName = collectionPersister.getTableName();
lhsColumnNames = collectionPersister.getElementColumnNames();
}
else {
final OuterJoinLoadable entityPersister = (OuterJoinLoadable) source();
lhsTableName = getLHSTableName( type, attributeNumber(), entityPersister );
lhsColumnNames = getLHSColumnNames( type, attributeNumber(), entityPersister, sessionFactory() );
}
return new AssociationKey( lhsTableName, lhsColumnNames );
}
else {
return new AssociationKey( joinable.getTableName(), getRHSColumnNames( type, sessionFactory() ) );
}
}
@Override
public AssociationNature getAssociationNature() {
if ( getType().isAnyType() ) {
return AssociationNature.ANY;
}
else {
if ( getType().isCollectionType() ) {
return AssociationNature.COLLECTION;
}
else {
return AssociationNature.ENTITY;
}
}
}
@Override
public AnyMappingDefinition toAnyDefinition() {
return new StandardAnyTypeDefinition(
(AnyType) getType(),
getSource().getEntityMetamodel().getProperties()[ attributeNumber() ].isLazy()
);
}
private Joinable joinable;
protected Joinable getJoinable() {
if ( getAssociationNature() == AssociationNature.ANY ) {
throw new WalkingException( "Cannot resolve AnyType to a Joinable" );
}
if ( joinable == null ) {
joinable = getType().getAssociatedJoinable( sessionFactory() );
}
return joinable;
}
@Override
public EntityDefinition toEntityDefinition() {
if ( getAssociationNature() == AssociationNature.ANY ) {
throw new WalkingException( "Cannot treat any-type attribute as an entity type" );
}
if ( getAssociationNature() == AssociationNature.COLLECTION ) {
throw new IllegalStateException( "Cannot treat collection-valued attribute as entity type" );
}
return (EntityPersister) getJoinable();
}
@Override
public CollectionDefinition toCollectionDefinition() {
if ( getAssociationNature() == AssociationNature.ANY ) {
throw new WalkingException( "Cannot treat any-type attribute as a collection type" );
}
if ( getAssociationNature() == AssociationNature.ENTITY ) {
throw new IllegalStateException( "Cannot treat entity-valued attribute as collection type" );
}
return (QueryableCollection) getJoinable();
}
@Override
public FetchOptions determineFetchPlan(LoadQueryInfluencers loadQueryInfluencers, PropertyPath propertyPath) {
final EntityPersister owningPersister = getSource().getEntityPersister();
FetchStyle style = FetchOptionsHelper.determineFetchStyleByProfile(
loadQueryInfluencers,
owningPersister,
propertyPath,
attributeNumber()
);
if ( style == null ) {
style = FetchOptionsHelper.determineFetchStyleByMetadata(
( (OuterJoinLoadable) getSource().getEntityPersister() ).getFetchMode( attributeNumber() ),
getType(),
sessionFactory()
);
}
final FetchTiming timing = FetchOptionsHelper.determineFetchTiming( style, getType(), sessionFactory() );
return FetchOptions.valueOf( timing, style );
}
@Override
public CascadeStyle determineCascadeStyle() {
return getSource().getEntityPersister().getPropertyCascadeStyles()[attributeNumber()];
}
private HydratedCompoundValueHandler hydratedCompoundValueHandler;
@Override
public HydratedCompoundValueHandler getHydratedCompoundValueExtractor() {
if ( hydratedCompoundValueHandler == null ) {
hydratedCompoundValueHandler = new HydratedCompoundValueHandler() {
@Override
public Object extract(Object hydratedState) {
return ( (Object[] ) hydratedState )[ attributeNumber() ];
}
@Override
public void inject(Object hydratedState, Object value) {
( (Object[] ) hydratedState )[ attributeNumber() ] = value;
}
};
}
return hydratedCompoundValueHandler;
}
@Override
protected String loggableMetadata() {

View File

@ -8,7 +8,7 @@ package org.hibernate.tuple.entity;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.walking.spi.CompositionDefinition;
import org.hibernate.persister.walking.spi.AttributeSource;
import org.hibernate.tuple.BaselineAttributeInformation;
import org.hibernate.tuple.component.AbstractCompositionAttribute;
import org.hibernate.type.CompositeType;
@ -18,7 +18,7 @@ import org.hibernate.type.CompositeType;
*/
public class EntityBasedCompositionAttribute
extends AbstractCompositionAttribute
implements CompositionDefinition {
implements AttributeSource {
public EntityBasedCompositionAttribute(
EntityPersister source,

View File

@ -35,7 +35,6 @@ import org.hibernate.engine.spi.EntityEntryFactory;
import org.hibernate.engine.spi.LoadQueryInfluencers;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.ValueInclusion;
import org.hibernate.id.IdentifierGenerator;
import org.hibernate.internal.FilterAliasGenerator;
import org.hibernate.loader.ast.spi.MultiIdLoadOptions;
@ -59,10 +58,6 @@ import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.CollectionElementDefinition;
import org.hibernate.persister.walking.spi.CollectionIndexDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.query.spi.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.sql.ast.Clause;
@ -114,10 +109,6 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
return new BytecodeEnhancementMetadataNonPojoImpl( null );
}
@Override
public void generateEntityDefinition() {
}
@Override
public void postInstantiate() throws MappingException {
@ -734,16 +725,6 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
return null;
}
@Override
public EntityIdentifierDefinition getEntityKeyDefinition() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
throw new NotYetImplementedException();
}
@Override
public int[] resolveAttributeIndexes(String[] attributeNames) {
return null;
@ -815,25 +796,10 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public CollectionPersister getCollectionPersister() {
return this;
}
public CollectionType getCollectionType() {
throw new NotYetImplementedException();
}
@Override
public CollectionIndexDefinition getIndexDefinition() {
throw new NotYetImplementedException();
}
@Override
public CollectionElementDefinition getElementDefinition() {
throw new NotYetImplementedException();
}
public Type getKeyType() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}

View File

@ -23,7 +23,7 @@ import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.entity.UniqueKeyLoadable;
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.AssociationType;

View File

@ -22,7 +22,7 @@ import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.entity.UniqueKeyLoadable;
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.AssociationType;

View File

@ -20,7 +20,7 @@ import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.persister.entity.UniqueKeyLoadable;
import org.hibernate.persister.walking.internal.FetchOptionsHelper;
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.AssociationType;

View File

@ -56,8 +56,6 @@ import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
import org.hibernate.persister.spi.PersisterClassResolver;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.query.spi.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
@ -132,10 +130,6 @@ public class PersisterClassProviderTest {
return new BytecodeEnhancementMetadataNonPojoImpl( getEntityName() );
}
@Override
public void generateEntityDefinition() {
}
@Override
public void postInstantiate() throws MappingException {
@ -714,16 +708,6 @@ public class PersisterClassProviderTest {
return this;
}
@Override
public EntityIdentifierDefinition getEntityKeyDefinition() {
return null;
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return null;
}
@Override
public boolean isAffectedByEnabledFilters(LoadQueryInfluencers influencers) {
return false;

View File

@ -55,8 +55,6 @@ import org.hibernate.metamodel.model.domain.NavigableRole;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.spi.PersisterCreationContext;
import org.hibernate.persister.walking.spi.AttributeDefinition;
import org.hibernate.persister.walking.spi.EntityIdentifierDefinition;
import org.hibernate.query.spi.NavigablePath;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
@ -119,10 +117,6 @@ public class CustomPersister implements EntityPersister {
return Custom.class;
}
@Override
public void generateEntityDefinition() {
}
public void postInstantiate() throws MappingException {}
public String getEntityName() {
@ -822,16 +816,6 @@ public class CustomPersister implements EntityPersister {
return null;
}
@Override
public EntityIdentifierDefinition getEntityKeyDefinition() {
throw new NotYetImplementedException();
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
throw new NotYetImplementedException();
}
@Override
public int[] resolveAttributeIndexes(String[] attributeNames) {
return null;