HHH-8629 : Integrate LoadPlans into collection initializers
This commit is contained in:
parent
faca8f5dd4
commit
fdf211fdd1
|
@ -24,12 +24,12 @@
|
||||||
package org.hibernate.loader.plan2.build.internal.returns;
|
package org.hibernate.loader.plan2.build.internal.returns;
|
||||||
|
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
import org.hibernate.loader.plan2.build.internal.spaces.CollectionQuerySpaceImpl;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCollectionQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.LoadPlanBuildingContext;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionFetchableElement;
|
import org.hibernate.loader.plan2.spi.CollectionFetchableElement;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionFetchableIndex;
|
import org.hibernate.loader.plan2.spi.CollectionFetchableIndex;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionReference;
|
import org.hibernate.loader.plan2.spi.CollectionReference;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
|
@ -40,26 +40,23 @@ import org.hibernate.type.Type;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCollectionReference implements CollectionReference {
|
public abstract class AbstractCollectionReference implements CollectionReference {
|
||||||
private final CollectionQuerySpaceImpl collectionQuerySpace;
|
private final ExpandingCollectionQuerySpace collectionQuerySpace;
|
||||||
private final PropertyPath propertyPath;
|
private final PropertyPath propertyPath;
|
||||||
|
|
||||||
private final CollectionFetchableIndex index;
|
private final CollectionFetchableIndex index;
|
||||||
private final CollectionFetchableElement element;
|
private final CollectionFetchableElement element;
|
||||||
|
|
||||||
protected AbstractCollectionReference(
|
protected AbstractCollectionReference(
|
||||||
CollectionQuerySpaceImpl collectionQuerySpace,
|
ExpandingCollectionQuerySpace collectionQuerySpace,
|
||||||
PropertyPath propertyPath,
|
PropertyPath propertyPath) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
this.collectionQuerySpace = collectionQuerySpace;
|
this.collectionQuerySpace = collectionQuerySpace;
|
||||||
this.propertyPath = propertyPath;
|
this.propertyPath = propertyPath;
|
||||||
|
|
||||||
this.index = buildIndexGraph( collectionQuerySpace, loadPlanBuildingContext );
|
this.index = buildIndexGraph( collectionQuerySpace );
|
||||||
this.element = buildElementGraph( collectionQuerySpace, loadPlanBuildingContext );
|
this.element = buildElementGraph( collectionQuerySpace );
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectionFetchableIndex buildIndexGraph(
|
private CollectionFetchableIndex buildIndexGraph(ExpandingCollectionQuerySpace collectionQuerySpace) {
|
||||||
CollectionQuerySpaceImpl collectionQuerySpace,
|
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
|
final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
|
||||||
if ( persister.hasIndex() ) {
|
if ( persister.hasIndex() ) {
|
||||||
final Type type = persister.getIndexType();
|
final Type type = persister.getIndexType();
|
||||||
|
@ -69,17 +66,17 @@ public abstract class AbstractCollectionReference implements CollectionReference
|
||||||
( (EntityType) type ).getAssociatedEntityName()
|
( (EntityType) type ).getAssociatedEntityName()
|
||||||
);
|
);
|
||||||
|
|
||||||
final Join join = collectionQuerySpace.addIndexEntityJoin(
|
final ExpandingEntityQuerySpace entityQuerySpace = collectionQuerySpace.addIndexEntityQuerySpace(
|
||||||
indexPersister
|
indexPersister
|
||||||
);
|
);
|
||||||
return new CollectionFetchableIndexEntityGraph( this, join );
|
return new CollectionFetchableIndexEntityGraph( this, entityQuerySpace );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type.isComponentType() ) {
|
||||||
final Join join = collectionQuerySpace.addIndexCompositeJoin(
|
final ExpandingCompositeQuerySpace compositeQuerySpace = collectionQuerySpace.addIndexCompositeQuerySpace(
|
||||||
(CompositeType) type
|
(CompositeType) type
|
||||||
);
|
);
|
||||||
return new CollectionFetchableIndexCompositeGraph( this, join );
|
return new CollectionFetchableIndexCompositeGraph( this, compositeQuerySpace );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,8 +84,7 @@ public abstract class AbstractCollectionReference implements CollectionReference
|
||||||
}
|
}
|
||||||
|
|
||||||
private CollectionFetchableElement buildElementGraph(
|
private CollectionFetchableElement buildElementGraph(
|
||||||
CollectionQuerySpaceImpl collectionQuerySpace,
|
ExpandingCollectionQuerySpace collectionQuerySpace) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
|
final CollectionPersister persister = collectionQuerySpace.getCollectionPersister();
|
||||||
final Type type = persister.getElementType();
|
final Type type = persister.getElementType();
|
||||||
if ( type.isAssociationType() ) {
|
if ( type.isAssociationType() ) {
|
||||||
|
@ -97,15 +93,17 @@ public abstract class AbstractCollectionReference implements CollectionReference
|
||||||
( (EntityType) type ).getAssociatedEntityName()
|
( (EntityType) type ).getAssociatedEntityName()
|
||||||
);
|
);
|
||||||
|
|
||||||
final Join join = collectionQuerySpace.addElementEntityJoin( elementPersister );
|
final ExpandingEntityQuerySpace entityQuerySpace = collectionQuerySpace.addElementEntityQuerySpace(
|
||||||
return new CollectionFetchableElementEntityGraph( this, join );
|
elementPersister
|
||||||
|
);
|
||||||
|
return new CollectionFetchableElementEntityGraph( this, entityQuerySpace );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( type.isComponentType() ) {
|
else if ( type.isComponentType() ) {
|
||||||
final Join join = collectionQuerySpace.addElementCompositeJoin(
|
final ExpandingCompositeQuerySpace compositeQuerySpace = collectionQuerySpace.addElementCompositeQuerySpace(
|
||||||
(CompositeType) type
|
(CompositeType) type
|
||||||
);
|
);
|
||||||
return new CollectionFetchableElementCompositeGraph( this, join );
|
return new CollectionFetchableElementCompositeGraph( this, compositeQuerySpace );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.hibernate.engine.FetchStyle;
|
||||||
import org.hibernate.engine.FetchTiming;
|
import org.hibernate.engine.FetchTiming;
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.LoadPlanBuildingContext;
|
|
||||||
import org.hibernate.loader.plan2.spi.CollectionFetch;
|
import org.hibernate.loader.plan2.spi.CollectionFetch;
|
||||||
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
||||||
import org.hibernate.loader.plan2.spi.EntityReference;
|
import org.hibernate.loader.plan2.spi.EntityReference;
|
||||||
|
@ -45,7 +44,7 @@ import org.hibernate.type.Type;
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractCompositeFetch extends AbstractExpandingFetchSource implements CompositeFetch {
|
public abstract class AbstractCompositeFetch extends AbstractExpandingFetchSource implements CompositeFetch {
|
||||||
private static final FetchStrategy FETCH_STRATEGY = new FetchStrategy( FetchTiming.IMMEDIATE, FetchStyle.JOIN );
|
protected static final FetchStrategy FETCH_STRATEGY = new FetchStrategy( FetchTiming.IMMEDIATE, FetchStyle.JOIN );
|
||||||
|
|
||||||
private final CompositeType compositeType;
|
private final CompositeType compositeType;
|
||||||
private final boolean allowCollectionFetches;
|
private final boolean allowCollectionFetches;
|
||||||
|
@ -104,8 +103,7 @@ public abstract class AbstractCompositeFetch extends AbstractExpandingFetchSourc
|
||||||
@Override
|
@Override
|
||||||
public CollectionFetch buildCollectionFetch(
|
public CollectionFetch buildCollectionFetch(
|
||||||
AssociationAttributeDefinition attributeDefinition,
|
AssociationAttributeDefinition attributeDefinition,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
if ( !allowCollectionFetches ) {
|
if ( !allowCollectionFetches ) {
|
||||||
throw new WalkingException(
|
throw new WalkingException(
|
||||||
String.format(
|
String.format(
|
||||||
|
@ -114,7 +112,7 @@ public abstract class AbstractCompositeFetch extends AbstractExpandingFetchSourc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return super.buildCollectionFetch( attributeDefinition, fetchStrategy, loadPlanBuildingContext );
|
return super.buildCollectionFetch( attributeDefinition, fetchStrategy );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,7 +29,6 @@ import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
||||||
import org.hibernate.loader.plan2.spi.EntityIdentifierDescription;
|
import org.hibernate.loader.plan2.spi.EntityIdentifierDescription;
|
||||||
import org.hibernate.loader.plan2.spi.EntityReference;
|
import org.hibernate.loader.plan2.spi.EntityReference;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
||||||
import org.hibernate.persister.walking.spi.EncapsulatedEntityIdentifierDefinition;
|
import org.hibernate.persister.walking.spi.EncapsulatedEntityIdentifierDefinition;
|
||||||
|
@ -73,27 +72,29 @@ public abstract class AbstractEntityReference extends AbstractExpandingFetchSour
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we get here, we know we have a composite identifier...
|
// if we get here, we know we have a composite identifier...
|
||||||
final Join join = expandingEntityQuerySpace().makeCompositeIdentifierJoin();
|
final ExpandingCompositeQuerySpace querySpace = expandingEntityQuerySpace().makeCompositeIdentifierQuerySpace();
|
||||||
return identifierDefinition.isEncapsulated()
|
return identifierDefinition.isEncapsulated()
|
||||||
? buildEncapsulatedCompositeIdentifierDescription( join )
|
? buildEncapsulatedCompositeIdentifierDescription( querySpace )
|
||||||
: buildNonEncapsulatedCompositeIdentifierDescription( join );
|
: buildNonEncapsulatedCompositeIdentifierDescription( querySpace );
|
||||||
}
|
}
|
||||||
|
|
||||||
private NonEncapsulatedEntityIdentifierDescription buildNonEncapsulatedCompositeIdentifierDescription(Join compositeJoin) {
|
private NonEncapsulatedEntityIdentifierDescription buildNonEncapsulatedCompositeIdentifierDescription(
|
||||||
|
ExpandingCompositeQuerySpace compositeQuerySpace) {
|
||||||
return new NonEncapsulatedEntityIdentifierDescription(
|
return new NonEncapsulatedEntityIdentifierDescription(
|
||||||
this,
|
this,
|
||||||
(ExpandingCompositeQuerySpace) compositeJoin.getRightHandSide(),
|
compositeQuerySpace,
|
||||||
(CompositeType) getEntityPersister().getIdentifierType(),
|
(CompositeType) getEntityPersister().getIdentifierType(),
|
||||||
getPropertyPath().append( "id" )
|
getPropertyPath().append( EntityPersister.ENTITY_ID )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EncapsulatedEntityIdentifierDescription buildEncapsulatedCompositeIdentifierDescription(Join compositeJoin) {
|
private EncapsulatedEntityIdentifierDescription buildEncapsulatedCompositeIdentifierDescription(
|
||||||
|
ExpandingCompositeQuerySpace compositeQuerySpace) {
|
||||||
return new EncapsulatedEntityIdentifierDescription(
|
return new EncapsulatedEntityIdentifierDescription(
|
||||||
this,
|
this,
|
||||||
(ExpandingCompositeQuerySpace) compositeJoin.getRightHandSide(),
|
compositeQuerySpace,
|
||||||
(CompositeType) getEntityPersister().getIdentifierType(),
|
(CompositeType) getEntityPersister().getIdentifierType(),
|
||||||
getPropertyPath().append( "id" )
|
getPropertyPath().append( EntityPersister.ENTITY_ID )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,25 +27,27 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.engine.FetchStrategy;
|
import org.hibernate.engine.FetchStrategy;
|
||||||
|
import org.hibernate.engine.FetchStyle;
|
||||||
|
import org.hibernate.engine.FetchTiming;
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingCollectionQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingFetchSource;
|
import org.hibernate.loader.plan2.build.spi.ExpandingFetchSource;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.loader.plan2.build.spi.LoadPlanBuildingContext;
|
import org.hibernate.loader.plan2.build.spi.ExpandingSourceQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.BidirectionalEntityReference;
|
import org.hibernate.loader.plan2.spi.BidirectionalEntityReference;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionFetch;
|
import org.hibernate.loader.plan2.spi.CollectionFetch;
|
||||||
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
||||||
import org.hibernate.loader.plan2.spi.EntityFetch;
|
import org.hibernate.loader.plan2.spi.EntityFetch;
|
||||||
import org.hibernate.loader.plan2.spi.EntityReference;
|
import org.hibernate.loader.plan2.spi.EntityReference;
|
||||||
import org.hibernate.loader.plan2.spi.Fetch;
|
import org.hibernate.loader.plan2.spi.Fetch;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
|
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
|
||||||
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
||||||
import org.hibernate.persister.walking.spi.WalkingException;
|
import org.hibernate.persister.walking.spi.WalkingException;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
import org.hibernate.type.CompositeType;
|
|
||||||
import org.hibernate.type.EntityType;
|
import org.hibernate.type.EntityType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -63,12 +65,12 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
private static final BidirectionalEntityReference[] NO_BIDIRECTIONAL_ENTITY_REFERENCES =
|
private static final BidirectionalEntityReference[] NO_BIDIRECTIONAL_ENTITY_REFERENCES =
|
||||||
new BidirectionalEntityReference[0];
|
new BidirectionalEntityReference[0];
|
||||||
|
|
||||||
private final ExpandingQuerySpace querySpace;
|
private final ExpandingSourceQuerySpace querySpace;
|
||||||
private final PropertyPath propertyPath;
|
private final PropertyPath propertyPath;
|
||||||
private List<Fetch> fetches;
|
private List<Fetch> fetches;
|
||||||
private List<BidirectionalEntityReference> bidirectionalEntityReferences;
|
private List<BidirectionalEntityReference> bidirectionalEntityReferences;
|
||||||
|
|
||||||
public AbstractExpandingFetchSource(ExpandingQuerySpace querySpace, PropertyPath propertyPath) {
|
public AbstractExpandingFetchSource(ExpandingSourceQuerySpace querySpace, PropertyPath propertyPath) {
|
||||||
this.querySpace = querySpace;
|
this.querySpace = querySpace;
|
||||||
this.propertyPath = propertyPath;
|
this.propertyPath = propertyPath;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +80,7 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
return querySpace.getUid();
|
return querySpace.getUid();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final ExpandingQuerySpace expandingQuerySpace() {
|
protected final ExpandingSourceQuerySpace expandingQuerySpace() {
|
||||||
return querySpace;
|
return querySpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,12 +120,9 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
@Override
|
@Override
|
||||||
public EntityFetch buildEntityFetch(
|
public EntityFetch buildEntityFetch(
|
||||||
AssociationAttributeDefinition attributeDefinition,
|
AssociationAttributeDefinition attributeDefinition,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
final EntityType fetchedType = (EntityType) attributeDefinition.getType();
|
final EntityType fetchedType = (EntityType) attributeDefinition.getType();
|
||||||
final EntityPersister fetchedPersister = loadPlanBuildingContext.getSessionFactory().getEntityPersister(
|
final EntityPersister fetchedPersister = attributeDefinition.toEntityDefinition().getEntityPersister();
|
||||||
fetchedType.getAssociatedEntityName()
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( fetchedPersister == null ) {
|
if ( fetchedPersister == null ) {
|
||||||
throw new WalkingException(
|
throw new WalkingException(
|
||||||
|
@ -135,13 +134,14 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final Join join = querySpace.addEntityJoin(
|
final ExpandingEntityQuerySpace entityQuerySpace = querySpace.addEntityQuerySpace(
|
||||||
attributeDefinition,
|
attributeDefinition,
|
||||||
fetchedPersister,
|
fetchedPersister,
|
||||||
loadPlanBuildingContext.getQuerySpaces().generateImplicitUid(),
|
getQuerySpaces().generateImplicitUid(),
|
||||||
attributeDefinition.isNullable()
|
attributeDefinition.isNullable(),
|
||||||
|
shouldIncludeJoin( fetchStrategy )
|
||||||
);
|
);
|
||||||
final EntityFetch fetch = new EntityFetchImpl( this, attributeDefinition, fetchStrategy, join );
|
final EntityFetch fetch = new EntityFetchImpl( this, attributeDefinition, fetchStrategy, entityQuerySpace );
|
||||||
addFetch( fetch );
|
addFetch( fetch );
|
||||||
return fetch;
|
return fetch;
|
||||||
}
|
}
|
||||||
|
@ -150,12 +150,9 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
public BidirectionalEntityReference buildBidirectionalEntityReference(
|
public BidirectionalEntityReference buildBidirectionalEntityReference(
|
||||||
AssociationAttributeDefinition attributeDefinition,
|
AssociationAttributeDefinition attributeDefinition,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy,
|
||||||
EntityReference targetEntityReference,
|
EntityReference targetEntityReference) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
final EntityType fetchedType = (EntityType) attributeDefinition.getType();
|
final EntityType fetchedType = (EntityType) attributeDefinition.getType();
|
||||||
final EntityPersister fetchedPersister = loadPlanBuildingContext.getSessionFactory().getEntityPersister(
|
final EntityPersister fetchedPersister = attributeDefinition.toEntityDefinition().getEntityPersister();
|
||||||
fetchedType.getAssociatedEntityName()
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( fetchedPersister == null ) {
|
if ( fetchedPersister == null ) {
|
||||||
throw new WalkingException(
|
throw new WalkingException(
|
||||||
|
@ -177,19 +174,20 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
CompositionDefinition compositeType,
|
CompositionDefinition compositeType,
|
||||||
ExpandingCompositeQuerySpace compositeQuerySpace);
|
ExpandingCompositeQuerySpace compositeQuerySpace);
|
||||||
|
|
||||||
|
protected ExpandingQuerySpaces getQuerySpaces() {
|
||||||
|
return querySpace.getExpandingQuerySpaces();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompositeFetch buildCompositeFetch(
|
public CompositeFetch buildCompositeFetch(
|
||||||
CompositionDefinition attributeDefinition,
|
CompositionDefinition attributeDefinition) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
final ExpandingSourceQuerySpace leftHandSide = expandingQuerySpace();
|
||||||
final ExpandingQuerySpace leftHandSide = expandingQuerySpace();
|
final ExpandingCompositeQuerySpace compositeQuerySpace = leftHandSide.addCompositeQuerySpace(
|
||||||
final Join join = leftHandSide.addCompositeJoin(
|
|
||||||
attributeDefinition,
|
attributeDefinition,
|
||||||
loadPlanBuildingContext.getQuerySpaces().generateImplicitUid()
|
getQuerySpaces().generateImplicitUid(),
|
||||||
);
|
shouldIncludeJoin( AbstractCompositeFetch.FETCH_STRATEGY )
|
||||||
final CompositeFetch fetch = createCompositeFetch(
|
|
||||||
attributeDefinition,
|
|
||||||
(ExpandingCompositeQuerySpace) join.getRightHandSide()
|
|
||||||
);
|
);
|
||||||
|
final CompositeFetch fetch = createCompositeFetch( attributeDefinition, compositeQuerySpace );
|
||||||
addFetch( fetch );
|
addFetch( fetch );
|
||||||
return fetch;
|
return fetch;
|
||||||
}
|
}
|
||||||
|
@ -197,16 +195,13 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
@Override
|
@Override
|
||||||
public CollectionFetch buildCollectionFetch(
|
public CollectionFetch buildCollectionFetch(
|
||||||
AssociationAttributeDefinition attributeDefinition,
|
AssociationAttributeDefinition attributeDefinition,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
|
|
||||||
// general question here wrt Joins and collection fetches... do we create multiple Joins for many-to-many,
|
// general question here wrt Joins and collection fetches... do we create multiple Joins for many-to-many,
|
||||||
// for example, or do we allow the Collection QuerySpace to handle that?
|
// for example, or do we allow the Collection QuerySpace to handle that?
|
||||||
|
|
||||||
final CollectionType fetchedType = (CollectionType) attributeDefinition.getType();
|
final CollectionType fetchedType = (CollectionType) attributeDefinition.getType();
|
||||||
final CollectionPersister fetchedPersister = loadPlanBuildingContext.getSessionFactory().getCollectionPersister(
|
final CollectionPersister fetchedPersister = attributeDefinition.toCollectionDefinition().getCollectionPersister();
|
||||||
fetchedType.getRole()
|
|
||||||
);
|
|
||||||
|
|
||||||
if ( fetchedPersister == null ) {
|
if ( fetchedPersister == null ) {
|
||||||
throw new WalkingException(
|
throw new WalkingException(
|
||||||
|
@ -217,20 +212,23 @@ public abstract class AbstractExpandingFetchSource implements ExpandingFetchSour
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final Join join = querySpace.addCollectionJoin(
|
final ExpandingCollectionQuerySpace collectionQuerySpace = querySpace.addCollectionQuerySpace(
|
||||||
attributeDefinition,
|
attributeDefinition,
|
||||||
fetchedPersister,
|
fetchedPersister,
|
||||||
loadPlanBuildingContext.getQuerySpaces().generateImplicitUid()
|
getQuerySpaces().generateImplicitUid(),
|
||||||
|
shouldIncludeJoin( fetchStrategy )
|
||||||
);
|
);
|
||||||
final CollectionFetch fetch = new CollectionFetchImpl(
|
final CollectionFetch fetch = new CollectionFetchImpl(
|
||||||
this,
|
this,
|
||||||
attributeDefinition,
|
attributeDefinition,
|
||||||
fetchStrategy,
|
fetchStrategy,
|
||||||
join,
|
collectionQuerySpace
|
||||||
loadPlanBuildingContext
|
|
||||||
);
|
);
|
||||||
addFetch( fetch );
|
addFetch( fetch );
|
||||||
return fetch;
|
return fetch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean shouldIncludeJoin(FetchStrategy fetchStrategy) {
|
||||||
|
return fetchStrategy.getTiming() == FetchTiming.IMMEDIATE && fetchStrategy.getStyle() == FetchStyle.JOIN;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,10 @@
|
||||||
package org.hibernate.loader.plan2.build.internal.returns;
|
package org.hibernate.loader.plan2.build.internal.returns;
|
||||||
|
|
||||||
import org.hibernate.engine.FetchStrategy;
|
import org.hibernate.engine.FetchStrategy;
|
||||||
import org.hibernate.loader.plan2.build.internal.spaces.CollectionQuerySpaceImpl;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCollectionQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingFetchSource;
|
import org.hibernate.loader.plan2.build.spi.ExpandingFetchSource;
|
||||||
import org.hibernate.loader.plan2.build.spi.LoadPlanBuildingContext;
|
|
||||||
import org.hibernate.loader.plan2.spi.CollectionFetch;
|
import org.hibernate.loader.plan2.spi.CollectionFetch;
|
||||||
import org.hibernate.loader.plan2.spi.FetchSource;
|
import org.hibernate.loader.plan2.spi.FetchSource;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
|
import org.hibernate.persister.walking.spi.AssociationAttributeDefinition;
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
import org.hibernate.type.CollectionType;
|
import org.hibernate.type.CollectionType;
|
||||||
|
@ -41,24 +39,20 @@ public class CollectionFetchImpl extends AbstractCollectionReference implements
|
||||||
private final ExpandingFetchSource fetchSource;
|
private final ExpandingFetchSource fetchSource;
|
||||||
private final AttributeDefinition fetchedAttribute;
|
private final AttributeDefinition fetchedAttribute;
|
||||||
private final FetchStrategy fetchStrategy;
|
private final FetchStrategy fetchStrategy;
|
||||||
private final Join fetchedJoin;
|
|
||||||
|
|
||||||
public CollectionFetchImpl(
|
public CollectionFetchImpl(
|
||||||
ExpandingFetchSource fetchSource,
|
ExpandingFetchSource fetchSource,
|
||||||
AssociationAttributeDefinition fetchedAttribute,
|
AssociationAttributeDefinition fetchedAttribute,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy,
|
||||||
Join fetchedJoin,
|
ExpandingCollectionQuerySpace collectionQuerySpace) {
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext) {
|
|
||||||
super(
|
super(
|
||||||
(CollectionQuerySpaceImpl) fetchedJoin.getRightHandSide(),
|
collectionQuerySpace,
|
||||||
fetchSource.getPropertyPath().append( fetchedAttribute.getName() ),
|
fetchSource.getPropertyPath().append( fetchedAttribute.getName() )
|
||||||
loadPlanBuildingContext
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.fetchSource = fetchSource;
|
this.fetchSource = fetchSource;
|
||||||
this.fetchedAttribute = fetchedAttribute;
|
this.fetchedAttribute = fetchedAttribute;
|
||||||
this.fetchStrategy = fetchStrategy;
|
this.fetchStrategy = fetchStrategy;
|
||||||
this.fetchedJoin = fetchedJoin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,7 +28,6 @@ import org.hibernate.loader.plan2.spi.CollectionFetchableElement;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionReference;
|
import org.hibernate.loader.plan2.spi.CollectionReference;
|
||||||
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
import org.hibernate.loader.plan2.spi.CompositeFetch;
|
||||||
import org.hibernate.loader.plan2.spi.FetchSource;
|
import org.hibernate.loader.plan2.spi.FetchSource;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,10 +41,12 @@ public class CollectionFetchableElementCompositeGraph
|
||||||
|
|
||||||
private final CollectionReference collectionReference;
|
private final CollectionReference collectionReference;
|
||||||
|
|
||||||
public CollectionFetchableElementCompositeGraph(CollectionReference collectionReference, Join compositeJoin) {
|
public CollectionFetchableElementCompositeGraph(
|
||||||
|
CollectionReference collectionReference,
|
||||||
|
ExpandingCompositeQuerySpace compositeQuerySpace) {
|
||||||
super(
|
super(
|
||||||
(CompositeType) compositeJoin.getRightHandSide().getPropertyMapping().getType(),
|
(CompositeType) compositeQuerySpace.getPropertyMapping().getType(),
|
||||||
(ExpandingCompositeQuerySpace) compositeJoin.getRightHandSide(),
|
compositeQuerySpace,
|
||||||
false,
|
false,
|
||||||
// these property paths are just informational...
|
// these property paths are just informational...
|
||||||
collectionReference.getPropertyPath().append( "<element>" )
|
collectionReference.getPropertyPath().append( "<element>" )
|
||||||
|
|
|
@ -27,8 +27,6 @@ import org.hibernate.engine.FetchStrategy;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionFetchableElement;
|
import org.hibernate.loader.plan2.spi.CollectionFetchableElement;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionReference;
|
import org.hibernate.loader.plan2.spi.CollectionReference;
|
||||||
import org.hibernate.loader.plan2.spi.EntityQuerySpace;
|
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,18 +34,16 @@ import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
*/
|
*/
|
||||||
public class CollectionFetchableElementEntityGraph extends AbstractEntityReference implements CollectionFetchableElement {
|
public class CollectionFetchableElementEntityGraph extends AbstractEntityReference implements CollectionFetchableElement {
|
||||||
private final CollectionReference collectionReference;
|
private final CollectionReference collectionReference;
|
||||||
private final EntityQuerySpace entityQuerySpace;
|
|
||||||
|
|
||||||
public CollectionFetchableElementEntityGraph(
|
public CollectionFetchableElementEntityGraph(
|
||||||
CollectionReference collectionReference,
|
CollectionReference collectionReference,
|
||||||
Join entityJoin) {
|
ExpandingEntityQuerySpace entityQuerySpace) {
|
||||||
super(
|
super(
|
||||||
(ExpandingEntityQuerySpace) entityJoin.getRightHandSide(),
|
entityQuerySpace,
|
||||||
collectionReference.getPropertyPath().append( "<elements>" )
|
collectionReference.getPropertyPath().append( "<elements>" )
|
||||||
);
|
);
|
||||||
|
|
||||||
this.collectionReference = collectionReference;
|
this.collectionReference = collectionReference;
|
||||||
this.entityQuerySpace = (EntityQuerySpace) entityJoin.getRightHandSide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -46,18 +46,18 @@ public class CollectionFetchableIndexCompositeGraph
|
||||||
|
|
||||||
public CollectionFetchableIndexCompositeGraph(
|
public CollectionFetchableIndexCompositeGraph(
|
||||||
CollectionReference collectionReference,
|
CollectionReference collectionReference,
|
||||||
Join compositeJoin) {
|
ExpandingCompositeQuerySpace compositeQuerySpace) {
|
||||||
super(
|
super(
|
||||||
extractIndexType( compositeJoin ),
|
extractIndexType( compositeQuerySpace ),
|
||||||
(ExpandingCompositeQuerySpace) compositeJoin.getRightHandSide(),
|
compositeQuerySpace,
|
||||||
false,
|
false,
|
||||||
collectionReference.getPropertyPath().append( "<index>" )
|
collectionReference.getPropertyPath().append( "<index>" )
|
||||||
);
|
);
|
||||||
this.collectionReference = collectionReference;
|
this.collectionReference = collectionReference;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CompositeType extractIndexType(Join compositeJoin) {
|
private static CompositeType extractIndexType(ExpandingCompositeQuerySpace compositeQuerySpace) {
|
||||||
final Type type = compositeJoin.getRightHandSide().getPropertyMapping().getType();
|
final Type type = compositeQuerySpace.getPropertyMapping().getType();
|
||||||
if ( CompositeType.class.isInstance( type ) ) {
|
if ( CompositeType.class.isInstance( type ) ) {
|
||||||
return (CompositeType) type;
|
return (CompositeType) type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,6 @@ import org.hibernate.engine.FetchStrategy;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionFetchableIndex;
|
import org.hibernate.loader.plan2.spi.CollectionFetchableIndex;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionReference;
|
import org.hibernate.loader.plan2.spi.CollectionReference;
|
||||||
import org.hibernate.loader.plan2.spi.EntityQuerySpace;
|
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -36,18 +34,16 @@ import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
*/
|
*/
|
||||||
public class CollectionFetchableIndexEntityGraph extends AbstractEntityReference implements CollectionFetchableIndex {
|
public class CollectionFetchableIndexEntityGraph extends AbstractEntityReference implements CollectionFetchableIndex {
|
||||||
private final CollectionReference collectionReference;
|
private final CollectionReference collectionReference;
|
||||||
private final EntityQuerySpace entityQuerySpace;
|
|
||||||
|
|
||||||
public CollectionFetchableIndexEntityGraph(
|
public CollectionFetchableIndexEntityGraph(
|
||||||
CollectionReference collectionReference,
|
CollectionReference collectionReference,
|
||||||
Join entityJoin) {
|
ExpandingEntityQuerySpace entityQuerySpace) {
|
||||||
super(
|
super(
|
||||||
(ExpandingEntityQuerySpace) entityJoin.getRightHandSide(),
|
entityQuerySpace,
|
||||||
collectionReference.getPropertyPath().append( "<index>" )
|
collectionReference.getPropertyPath().append( "<index>" )
|
||||||
);
|
);
|
||||||
|
|
||||||
this.collectionReference = collectionReference;
|
this.collectionReference = collectionReference;
|
||||||
this.entityQuerySpace = (EntityQuerySpace) entityJoin.getRightHandSide();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -24,8 +24,7 @@
|
||||||
package org.hibernate.loader.plan2.build.internal.returns;
|
package org.hibernate.loader.plan2.build.internal.returns;
|
||||||
|
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
import org.hibernate.loader.plan2.build.internal.spaces.CollectionQuerySpaceImpl;
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.loader.plan2.build.spi.LoadPlanBuildingContext;
|
|
||||||
import org.hibernate.loader.plan2.spi.CollectionReturn;
|
import org.hibernate.loader.plan2.spi.CollectionReturn;
|
||||||
import org.hibernate.persister.walking.spi.CollectionDefinition;
|
import org.hibernate.persister.walking.spi.CollectionDefinition;
|
||||||
|
|
||||||
|
@ -34,14 +33,13 @@ import org.hibernate.persister.walking.spi.CollectionDefinition;
|
||||||
*/
|
*/
|
||||||
public class CollectionReturnImpl extends AbstractCollectionReference implements CollectionReturn {
|
public class CollectionReturnImpl extends AbstractCollectionReference implements CollectionReturn {
|
||||||
|
|
||||||
public CollectionReturnImpl(CollectionDefinition collectionDefinition, LoadPlanBuildingContext context) {
|
public CollectionReturnImpl(CollectionDefinition collectionDefinition, ExpandingQuerySpaces querySpaces) {
|
||||||
super(
|
super(
|
||||||
(CollectionQuerySpaceImpl) context.getQuerySpaces().makeCollectionQuerySpace(
|
querySpaces.makeRootCollectionQuerySpace(
|
||||||
context.getQuerySpaces().generateImplicitUid(),
|
querySpaces.generateImplicitUid(),
|
||||||
collectionDefinition.getCollectionPersister()
|
collectionDefinition.getCollectionPersister()
|
||||||
),
|
),
|
||||||
new PropertyPath( "[" + collectionDefinition.getCollectionPersister().getRole() + "]" ),
|
new PropertyPath( "[" + collectionDefinition.getCollectionPersister().getRole() + "]" )
|
||||||
context
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,9 @@ public class EntityFetchImpl extends AbstractEntityReference implements EntityFe
|
||||||
ExpandingFetchSource fetchSource,
|
ExpandingFetchSource fetchSource,
|
||||||
AssociationAttributeDefinition fetchedAttribute,
|
AssociationAttributeDefinition fetchedAttribute,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy,
|
||||||
Join fetchedJoin) {
|
ExpandingEntityQuerySpace entityQuerySpace) {
|
||||||
super(
|
super(
|
||||||
(ExpandingEntityQuerySpace) fetchedJoin.getRightHandSide(),
|
entityQuerySpace,
|
||||||
fetchSource.getPropertyPath().append( fetchedAttribute.getName() )
|
fetchSource.getPropertyPath().append( fetchedAttribute.getName() )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ package org.hibernate.loader.plan2.build.internal.returns;
|
||||||
import org.hibernate.engine.FetchStrategy;
|
import org.hibernate.engine.FetchStrategy;
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingFetchSource;
|
import org.hibernate.loader.plan2.build.spi.ExpandingFetchSource;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.loader.plan2.build.spi.LoadPlanBuildingContext;
|
import org.hibernate.loader.plan2.build.spi.LoadPlanBuildingContext;
|
||||||
import org.hibernate.loader.plan2.spi.EntityReturn;
|
import org.hibernate.loader.plan2.spi.EntityReturn;
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
|
@ -35,10 +36,10 @@ import org.hibernate.persister.walking.spi.EntityDefinition;
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class EntityReturnImpl extends AbstractEntityReference implements EntityReturn, ExpandingFetchSource {
|
public class EntityReturnImpl extends AbstractEntityReference implements EntityReturn, ExpandingFetchSource {
|
||||||
public EntityReturnImpl(EntityDefinition entityDefinition, LoadPlanBuildingContext loadPlanBuildingContext) {
|
public EntityReturnImpl(EntityDefinition entityDefinition, ExpandingQuerySpaces querySpaces) {
|
||||||
super(
|
super(
|
||||||
loadPlanBuildingContext.getQuerySpaces().makeEntityQuerySpace(
|
querySpaces.makeRootEntityQuerySpace(
|
||||||
loadPlanBuildingContext.getQuerySpaces().generateImplicitUid(),
|
querySpaces.generateImplicitUid(),
|
||||||
entityDefinition.getEntityPersister()
|
entityDefinition.getEntityPersister()
|
||||||
),
|
),
|
||||||
new PropertyPath( entityDefinition.getEntityPersister().getEntityName() )
|
new PropertyPath( entityDefinition.getEntityPersister().getEntityName() )
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.loader.plan2.build.internal.spaces;
|
||||||
|
|
||||||
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingCollectionQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingSourceQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
||||||
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
import org.hibernate.persister.entity.Queryable;
|
||||||
|
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
||||||
|
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
||||||
|
import org.hibernate.type.CollectionType;
|
||||||
|
import org.hibernate.type.EntityType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gail Badner
|
||||||
|
*/
|
||||||
|
public abstract class AbstractExpandingSourceQuerySpace extends AbstractQuerySpace implements ExpandingSourceQuerySpace {
|
||||||
|
|
||||||
|
public AbstractExpandingSourceQuerySpace(
|
||||||
|
String uid,
|
||||||
|
Disposition disposition,
|
||||||
|
ExpandingQuerySpaces querySpaces,
|
||||||
|
boolean canJoinsBeRequired,
|
||||||
|
SessionFactoryImplementor sessionFactory) {
|
||||||
|
super( uid, disposition, querySpaces, canJoinsBeRequired, sessionFactory );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExpandingCompositeQuerySpace addCompositeQuerySpace(
|
||||||
|
CompositionDefinition compositionDefinition,
|
||||||
|
String querySpaceUid,
|
||||||
|
boolean shouldIncludeJoin) {
|
||||||
|
final boolean required = canJoinsBeRequired() && !compositionDefinition.isNullable();
|
||||||
|
|
||||||
|
final ExpandingCompositeQuerySpace rhs = getExpandingQuerySpaces().makeCompositeQuerySpace(
|
||||||
|
querySpaceUid,
|
||||||
|
new CompositePropertyMapping(
|
||||||
|
compositionDefinition.getType(),
|
||||||
|
getPropertyMapping(),
|
||||||
|
compositionDefinition.getName()
|
||||||
|
),
|
||||||
|
required
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( shouldIncludeJoin ) {
|
||||||
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
||||||
|
this,
|
||||||
|
compositionDefinition.getName(),
|
||||||
|
rhs,
|
||||||
|
required,
|
||||||
|
compositionDefinition.getType()
|
||||||
|
);
|
||||||
|
internalGetJoins().add( join );
|
||||||
|
}
|
||||||
|
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExpandingEntityQuerySpace addEntityQuerySpace(
|
||||||
|
AttributeDefinition attribute,
|
||||||
|
EntityPersister persister,
|
||||||
|
String querySpaceUid,
|
||||||
|
boolean optional,
|
||||||
|
boolean shouldIncludeJoin) {
|
||||||
|
// TODO: Queryable.isMultiTable() may be more broad than it needs to be...
|
||||||
|
final boolean isMultiTable = Queryable.class.cast( persister ).isMultiTable();
|
||||||
|
final boolean required = canJoinsBeRequired() && !isMultiTable && !optional;
|
||||||
|
|
||||||
|
final ExpandingEntityQuerySpace rhs = getExpandingQuerySpaces().makeEntityQuerySpace(
|
||||||
|
querySpaceUid,
|
||||||
|
persister,
|
||||||
|
required
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( shouldIncludeJoin ) {
|
||||||
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(
|
||||||
|
this,
|
||||||
|
attribute.getName(),
|
||||||
|
rhs,
|
||||||
|
required,
|
||||||
|
(EntityType) attribute.getType(),
|
||||||
|
sessionFactory()
|
||||||
|
);
|
||||||
|
internalGetJoins().add( join );
|
||||||
|
}
|
||||||
|
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExpandingCollectionQuerySpace addCollectionQuerySpace(
|
||||||
|
AttributeDefinition attributeDefinition,
|
||||||
|
CollectionPersister collectionPersister,
|
||||||
|
String querySpaceUid,
|
||||||
|
boolean shouldIncludeJoin) {
|
||||||
|
final boolean required = canJoinsBeRequired() && !attributeDefinition.isNullable();
|
||||||
|
|
||||||
|
final ExpandingCollectionQuerySpace rhs = getExpandingQuerySpaces().makeCollectionQuerySpace(
|
||||||
|
querySpaceUid,
|
||||||
|
collectionPersister,
|
||||||
|
required
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( shouldIncludeJoin ) {
|
||||||
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCollectionJoin(
|
||||||
|
this,
|
||||||
|
attributeDefinition.getName(),
|
||||||
|
rhs,
|
||||||
|
required,
|
||||||
|
(CollectionType) attributeDefinition.getType(),
|
||||||
|
sessionFactory()
|
||||||
|
);
|
||||||
|
internalGetJoins().add( join );
|
||||||
|
}
|
||||||
|
|
||||||
|
return rhs;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExpandingQuerySpaces getExpandingQuerySpaces() {
|
||||||
|
return super.getExpandingQuerySpaces();
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,17 +21,18 @@
|
||||||
* 51 Franklin Street, Fifth Floor
|
* 51 Franklin Street, Fifth Floor
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
package org.hibernate.loader.plan2.build.spi;
|
package org.hibernate.loader.plan2.build.internal.spaces;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.loader.plan2.spi.AbstractPlanNode;
|
import org.hibernate.loader.plan2.spi.AbstractPlanNode;
|
||||||
import org.hibernate.loader.plan2.build.internal.spaces.QuerySpacesImpl;
|
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
import org.hibernate.loader.plan2.spi.Join;
|
||||||
import org.hibernate.loader.plan2.spi.QuerySpace;
|
import org.hibernate.loader.plan2.spi.QuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.spi.QuerySpaces;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience base class for QuerySpace implementations.
|
* Convenience base class for QuerySpace implementations.
|
||||||
|
@ -41,7 +42,7 @@ import org.hibernate.loader.plan2.spi.QuerySpace;
|
||||||
public abstract class AbstractQuerySpace extends AbstractPlanNode implements QuerySpace {
|
public abstract class AbstractQuerySpace extends AbstractPlanNode implements QuerySpace {
|
||||||
private final String uid;
|
private final String uid;
|
||||||
private final Disposition disposition;
|
private final Disposition disposition;
|
||||||
private final QuerySpacesImpl querySpaces;
|
private final ExpandingQuerySpaces querySpaces;
|
||||||
private final boolean canJoinsBeRequired;
|
private final boolean canJoinsBeRequired;
|
||||||
|
|
||||||
private List<Join> joins;
|
private List<Join> joins;
|
||||||
|
@ -49,7 +50,7 @@ public abstract class AbstractQuerySpace extends AbstractPlanNode implements Que
|
||||||
public AbstractQuerySpace(
|
public AbstractQuerySpace(
|
||||||
String uid,
|
String uid,
|
||||||
Disposition disposition,
|
Disposition disposition,
|
||||||
QuerySpacesImpl querySpaces,
|
ExpandingQuerySpaces querySpaces,
|
||||||
boolean canJoinsBeRequired,
|
boolean canJoinsBeRequired,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
super( sessionFactory );
|
super( sessionFactory );
|
||||||
|
@ -80,7 +81,11 @@ public abstract class AbstractQuerySpace extends AbstractPlanNode implements Que
|
||||||
*
|
*
|
||||||
* @return The query spaces
|
* @return The query spaces
|
||||||
*/
|
*/
|
||||||
public QuerySpacesImpl getQuerySpaces() {
|
public QuerySpaces getQuerySpaces() {
|
||||||
|
return querySpaces;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ExpandingQuerySpaces getExpandingQuerySpaces() {
|
||||||
return querySpaces;
|
return querySpaces;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,10 @@
|
||||||
package org.hibernate.loader.plan2.build.internal.spaces;
|
package org.hibernate.loader.plan2.build.internal.spaces;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.loader.plan2.build.spi.AbstractQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCollectionQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.collection.CollectionPropertyMapping;
|
import org.hibernate.persister.collection.CollectionPropertyMapping;
|
||||||
|
@ -40,14 +41,14 @@ import org.hibernate.type.EntityType;
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class CollectionQuerySpaceImpl extends AbstractQuerySpace implements CollectionQuerySpace {
|
public class CollectionQuerySpaceImpl extends AbstractQuerySpace implements ExpandingCollectionQuerySpace {
|
||||||
private final CollectionPersister persister;
|
private final CollectionPersister persister;
|
||||||
private final CollectionPropertyMapping propertyMapping;
|
private final CollectionPropertyMapping propertyMapping;
|
||||||
|
|
||||||
public CollectionQuerySpaceImpl(
|
public CollectionQuerySpaceImpl(
|
||||||
CollectionPersister persister,
|
CollectionPersister persister,
|
||||||
String uid,
|
String uid,
|
||||||
QuerySpacesImpl querySpaces,
|
ExpandingQuerySpaces querySpaces,
|
||||||
boolean canJoinsBeRequired,
|
boolean canJoinsBeRequired,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
super( uid, Disposition.COLLECTION, querySpaces, canJoinsBeRequired, sessionFactory );
|
super( uid, Disposition.COLLECTION, querySpaces, canJoinsBeRequired, sessionFactory );
|
||||||
|
@ -65,47 +66,44 @@ public class CollectionQuerySpaceImpl extends AbstractQuerySpace implements Coll
|
||||||
return propertyMapping;
|
return propertyMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinDefinedByMetadata addIndexEntityJoin(final EntityPersister indexPersister) {
|
@Override
|
||||||
|
public ExpandingEntityQuerySpace addIndexEntityQuerySpace(
|
||||||
|
final EntityPersister indexPersister) {
|
||||||
final boolean required = canJoinsBeRequired();
|
final boolean required = canJoinsBeRequired();
|
||||||
final String entityQuerySpaceUid = getQuerySpaces().generateImplicitUid();
|
final String entityQuerySpaceUid = getExpandingQuerySpaces().generateImplicitUid();
|
||||||
final EntityQuerySpaceImpl entityQuerySpace = new EntityQuerySpaceImpl(
|
final ExpandingEntityQuerySpace entityQuerySpace = getExpandingQuerySpaces().makeEntityQuerySpace(
|
||||||
indexPersister,
|
|
||||||
entityQuerySpaceUid,
|
entityQuerySpaceUid,
|
||||||
getQuerySpaces(),
|
indexPersister,
|
||||||
required,
|
required
|
||||||
sessionFactory()
|
|
||||||
);
|
);
|
||||||
getQuerySpaces().registerQuerySpace( entityQuerySpace );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(
|
||||||
this,
|
this,
|
||||||
// collection persister maps its index (through its PropertyMapping contract) as non-prefixed
|
// collection persister maps its index (through its PropertyMapping contract) as non-prefixed
|
||||||
CollectionPropertyNames.COLLECTION_INDICES,
|
CollectionPropertyNames.COLLECTION_INDICES,
|
||||||
entityQuerySpace,
|
entityQuerySpace,
|
||||||
canJoinsBeRequired(),
|
required,
|
||||||
(EntityType) persister.getIndexType(),
|
(EntityType) persister.getIndexType(),
|
||||||
sessionFactory()
|
sessionFactory()
|
||||||
);
|
);
|
||||||
|
|
||||||
internalGetJoins().add( join );
|
internalGetJoins().add( join );
|
||||||
|
|
||||||
return join;
|
return entityQuerySpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinDefinedByMetadata addIndexCompositeJoin(CompositeType compositeType) {
|
@Override
|
||||||
final String compositeQuerySpaceUid = getQuerySpaces().generateImplicitUid();
|
public ExpandingCompositeQuerySpace addIndexCompositeQuerySpace(
|
||||||
final CompositeQuerySpaceImpl compositeQuerySpace = new CompositeQuerySpaceImpl(
|
CompositeType compositeType) {
|
||||||
|
final String compositeQuerySpaceUid = getExpandingQuerySpaces().generateImplicitUid();
|
||||||
|
final ExpandingCompositeQuerySpace compositeQuerySpace = getExpandingQuerySpaces().makeCompositeQuerySpace(
|
||||||
|
compositeQuerySpaceUid,
|
||||||
new CompositePropertyMapping(
|
new CompositePropertyMapping(
|
||||||
compositeType,
|
compositeType,
|
||||||
(PropertyMapping) getCollectionPersister(),
|
(PropertyMapping) getCollectionPersister(),
|
||||||
"index"
|
"index"
|
||||||
),
|
),
|
||||||
compositeQuerySpaceUid,
|
canJoinsBeRequired()
|
||||||
getQuerySpaces(),
|
|
||||||
canJoinsBeRequired(),
|
|
||||||
sessionFactory()
|
|
||||||
);
|
);
|
||||||
getQuerySpaces().registerQuerySpace( compositeQuerySpace );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
||||||
this,
|
this,
|
||||||
|
@ -116,19 +114,18 @@ public class CollectionQuerySpaceImpl extends AbstractQuerySpace implements Coll
|
||||||
);
|
);
|
||||||
internalGetJoins().add( join );
|
internalGetJoins().add( join );
|
||||||
|
|
||||||
return join;
|
return compositeQuerySpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinDefinedByMetadata addElementEntityJoin(final EntityPersister elementPersister) {
|
@Override
|
||||||
final String entityQuerySpaceUid = getQuerySpaces().generateImplicitUid();
|
public ExpandingEntityQuerySpace addElementEntityQuerySpace(
|
||||||
final EntityQuerySpaceImpl entityQuerySpace = new EntityQuerySpaceImpl(
|
final EntityPersister elementPersister) {
|
||||||
elementPersister,
|
final String entityQuerySpaceUid = getExpandingQuerySpaces().generateImplicitUid();
|
||||||
|
final ExpandingEntityQuerySpace entityQuerySpace = getExpandingQuerySpaces().makeEntityQuerySpace(
|
||||||
entityQuerySpaceUid,
|
entityQuerySpaceUid,
|
||||||
getQuerySpaces(),
|
elementPersister,
|
||||||
canJoinsBeRequired(),
|
canJoinsBeRequired()
|
||||||
sessionFactory()
|
|
||||||
);
|
);
|
||||||
getQuerySpaces().registerQuerySpace( entityQuerySpace );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(
|
||||||
this,
|
this,
|
||||||
|
@ -141,25 +138,23 @@ public class CollectionQuerySpaceImpl extends AbstractQuerySpace implements Coll
|
||||||
);
|
);
|
||||||
internalGetJoins().add( join );
|
internalGetJoins().add( join );
|
||||||
|
|
||||||
return join;
|
return entityQuerySpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JoinDefinedByMetadata addElementCompositeJoin(
|
@Override
|
||||||
|
public ExpandingCompositeQuerySpace addElementCompositeQuerySpace(
|
||||||
CompositeType compositeType) {
|
CompositeType compositeType) {
|
||||||
final String compositeQuerySpaceUid = getQuerySpaces().generateImplicitUid();
|
final String compositeQuerySpaceUid = getExpandingQuerySpaces().generateImplicitUid();
|
||||||
|
|
||||||
final CompositeQuerySpaceImpl compositeQuerySpace = new CompositeQuerySpaceImpl(
|
final ExpandingCompositeQuerySpace compositeQuerySpace = getExpandingQuerySpaces().makeCompositeQuerySpace(
|
||||||
|
compositeQuerySpaceUid,
|
||||||
new CompositePropertyMapping(
|
new CompositePropertyMapping(
|
||||||
compositeType,
|
compositeType,
|
||||||
(PropertyMapping) getCollectionPersister(),
|
(PropertyMapping) getCollectionPersister(),
|
||||||
""
|
""
|
||||||
),
|
),
|
||||||
compositeQuerySpaceUid,
|
canJoinsBeRequired()
|
||||||
getQuerySpaces(),
|
|
||||||
canJoinsBeRequired(),
|
|
||||||
sessionFactory()
|
|
||||||
);
|
);
|
||||||
getQuerySpaces().registerQuerySpace( compositeQuerySpace );
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
||||||
this,
|
this,
|
||||||
// collection persister maps its elements (through its PropertyMapping contract) as non-prefixed
|
// collection persister maps its elements (through its PropertyMapping contract) as non-prefixed
|
||||||
|
@ -170,6 +165,6 @@ public class CollectionQuerySpaceImpl extends AbstractQuerySpace implements Coll
|
||||||
);
|
);
|
||||||
internalGetJoins().add( join );
|
internalGetJoins().add( join );
|
||||||
|
|
||||||
return join;
|
return compositeQuerySpace;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,142 +24,28 @@
|
||||||
package org.hibernate.loader.plan2.build.internal.spaces;
|
package org.hibernate.loader.plan2.build.internal.spaces;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.loader.plan2.build.spi.AbstractQuerySpace;
|
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
|
||||||
import org.hibernate.persister.entity.PropertyMapping;
|
import org.hibernate.persister.entity.PropertyMapping;
|
||||||
import org.hibernate.persister.entity.Queryable;
|
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
|
||||||
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
|
||||||
import org.hibernate.type.CollectionType;
|
|
||||||
import org.hibernate.type.EntityType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class CompositeQuerySpaceImpl extends AbstractQuerySpace implements ExpandingCompositeQuerySpace {
|
public class CompositeQuerySpaceImpl extends AbstractExpandingSourceQuerySpace implements ExpandingCompositeQuerySpace {
|
||||||
private final CompositePropertyMapping compositeSubPropertyMapping;
|
private final CompositePropertyMapping compositeSubPropertyMapping;
|
||||||
|
|
||||||
public CompositeQuerySpaceImpl(
|
public CompositeQuerySpaceImpl(
|
||||||
CompositePropertyMapping compositeSubPropertyMapping,
|
CompositePropertyMapping compositeSubPropertyMapping,
|
||||||
String uid,
|
String uid,
|
||||||
QuerySpacesImpl querySpaces,
|
ExpandingQuerySpaces querySpaces,
|
||||||
boolean canJoinsBeRequired,
|
boolean canJoinsBeRequired,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
super( uid, Disposition.COMPOSITE, querySpaces, canJoinsBeRequired, sessionFactory );
|
super( uid, Disposition.COMPOSITE, querySpaces, canJoinsBeRequired, sessionFactory );
|
||||||
this.compositeSubPropertyMapping = compositeSubPropertyMapping;
|
this.compositeSubPropertyMapping = compositeSubPropertyMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CompositeQuerySpaceImpl(
|
|
||||||
EntityQuerySpaceImpl entityQuerySpace,
|
|
||||||
CompositePropertyMapping compositePropertyMapping,
|
|
||||||
String uid,
|
|
||||||
boolean canJoinsBeRequired) {
|
|
||||||
// todo : we may need to keep around the owning entity query space to be able to properly handle circularity...
|
|
||||||
this(
|
|
||||||
compositePropertyMapping,
|
|
||||||
uid,
|
|
||||||
entityQuerySpace.getQuerySpaces(),
|
|
||||||
canJoinsBeRequired,
|
|
||||||
entityQuerySpace.sessionFactory()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PropertyMapping getPropertyMapping() {
|
public PropertyMapping getPropertyMapping() {
|
||||||
return compositeSubPropertyMapping;
|
return compositeSubPropertyMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public JoinDefinedByMetadata addCompositeJoin(CompositionDefinition compositionDefinition, String querySpaceUid) {
|
|
||||||
final boolean required = canJoinsBeRequired() && !compositionDefinition.isNullable();
|
|
||||||
|
|
||||||
final CompositeQuerySpaceImpl rhs = new CompositeQuerySpaceImpl(
|
|
||||||
new CompositePropertyMapping(
|
|
||||||
compositionDefinition.getType(),
|
|
||||||
compositeSubPropertyMapping,
|
|
||||||
compositionDefinition.getName()
|
|
||||||
),
|
|
||||||
querySpaceUid,
|
|
||||||
getQuerySpaces(),
|
|
||||||
required,
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
getQuerySpaces().registerQuerySpace( rhs );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
|
||||||
this,
|
|
||||||
compositionDefinition.getName(),
|
|
||||||
rhs,
|
|
||||||
required,
|
|
||||||
compositionDefinition.getType()
|
|
||||||
);
|
|
||||||
internalGetJoins().add( join );
|
|
||||||
|
|
||||||
return join;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JoinDefinedByMetadata addEntityJoin(
|
|
||||||
AttributeDefinition attributeDefinition,
|
|
||||||
EntityPersister persister,
|
|
||||||
String querySpaceUid,
|
|
||||||
boolean optional) {
|
|
||||||
// TODO: Queryable.isMultiTable() may be more broad than it needs to be...
|
|
||||||
final boolean isMultiTable = Queryable.class.cast( persister ).isMultiTable();
|
|
||||||
final boolean required = canJoinsBeRequired() && !isMultiTable && !optional;
|
|
||||||
|
|
||||||
final EntityQuerySpaceImpl rhs = new EntityQuerySpaceImpl(
|
|
||||||
persister,
|
|
||||||
querySpaceUid,
|
|
||||||
getQuerySpaces(),
|
|
||||||
required,
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
getQuerySpaces().registerQuerySpace( rhs );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(
|
|
||||||
this,
|
|
||||||
attributeDefinition.getName(),
|
|
||||||
rhs,
|
|
||||||
required,
|
|
||||||
(EntityType) attributeDefinition.getType(),
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
|
|
||||||
internalGetJoins().add( join );
|
|
||||||
|
|
||||||
return join;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JoinDefinedByMetadata addCollectionJoin(
|
|
||||||
AttributeDefinition attributeDefinition,
|
|
||||||
CollectionPersister collectionPersister,
|
|
||||||
String querySpaceUid) {
|
|
||||||
final boolean required = canJoinsBeRequired() && ! attributeDefinition.isNullable();
|
|
||||||
|
|
||||||
final CollectionQuerySpaceImpl rhs = new CollectionQuerySpaceImpl(
|
|
||||||
collectionPersister,
|
|
||||||
querySpaceUid,
|
|
||||||
getQuerySpaces(),
|
|
||||||
required,
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
getQuerySpaces().registerQuerySpace( rhs );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCollectionJoin(
|
|
||||||
this,
|
|
||||||
attributeDefinition.getName(),
|
|
||||||
rhs, required,
|
|
||||||
(CollectionType) attributeDefinition.getType(),
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
|
|
||||||
internalGetJoins().add( join );
|
|
||||||
|
|
||||||
return join;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,30 +24,24 @@
|
||||||
package org.hibernate.loader.plan2.build.internal.spaces;
|
package org.hibernate.loader.plan2.build.internal.spaces;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.loader.plan2.build.spi.AbstractQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.entity.PropertyMapping;
|
import org.hibernate.persister.entity.PropertyMapping;
|
||||||
import org.hibernate.persister.entity.Queryable;
|
|
||||||
import org.hibernate.persister.walking.spi.AttributeDefinition;
|
|
||||||
import org.hibernate.persister.walking.spi.CompositionDefinition;
|
|
||||||
import org.hibernate.type.CollectionType;
|
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
import org.hibernate.type.EntityType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class EntityQuerySpaceImpl extends AbstractQuerySpace implements ExpandingEntityQuerySpace {
|
public class EntityQuerySpaceImpl extends AbstractExpandingSourceQuerySpace implements ExpandingEntityQuerySpace {
|
||||||
private final EntityPersister persister;
|
private final EntityPersister persister;
|
||||||
|
|
||||||
public EntityQuerySpaceImpl(
|
public EntityQuerySpaceImpl(
|
||||||
EntityPersister persister,
|
EntityPersister persister,
|
||||||
String uid,
|
String uid,
|
||||||
QuerySpacesImpl querySpaces,
|
ExpandingQuerySpaces querySpaces,
|
||||||
boolean canJoinsBeRequired,
|
boolean canJoinsBeRequired,
|
||||||
SessionFactoryImplementor sessionFactory) {
|
SessionFactoryImplementor sessionFactory) {
|
||||||
super( uid, Disposition.ENTITY, querySpaces, canJoinsBeRequired, sessionFactory );
|
super( uid, Disposition.ENTITY, querySpaces, canJoinsBeRequired, sessionFactory );
|
||||||
|
@ -72,109 +66,17 @@ public class EntityQuerySpaceImpl extends AbstractQuerySpace implements Expandin
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JoinDefinedByMetadata addCompositeJoin(CompositionDefinition compositionDefinition, String querySpaceUid) {
|
public ExpandingCompositeQuerySpace makeCompositeIdentifierQuerySpace() {
|
||||||
final boolean required = canJoinsBeRequired() && !compositionDefinition.isNullable();
|
|
||||||
|
|
||||||
final CompositeQuerySpaceImpl rhs = new CompositeQuerySpaceImpl(
|
|
||||||
new CompositePropertyMapping(
|
|
||||||
compositionDefinition.getType(),
|
|
||||||
(PropertyMapping) this.getEntityPersister(),
|
|
||||||
compositionDefinition.getName()
|
|
||||||
),
|
|
||||||
querySpaceUid,
|
|
||||||
getQuerySpaces(),
|
|
||||||
required,
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
getQuerySpaces().registerQuerySpace( rhs );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
|
||||||
this,
|
|
||||||
compositionDefinition.getName(),
|
|
||||||
rhs,
|
|
||||||
required,
|
|
||||||
compositionDefinition.getType()
|
|
||||||
);
|
|
||||||
internalGetJoins().add( join );
|
|
||||||
|
|
||||||
return join;
|
|
||||||
}
|
|
||||||
|
|
||||||
public JoinDefinedByMetadata addEntityJoin(
|
|
||||||
AttributeDefinition attribute,
|
|
||||||
EntityPersister persister,
|
|
||||||
String querySpaceUid,
|
|
||||||
boolean optional) {
|
|
||||||
// TODO: Queryable.isMultiTable() may be more broad than it needs to be...
|
|
||||||
final boolean isMultiTable = Queryable.class.cast( persister ).isMultiTable();
|
|
||||||
final boolean required = canJoinsBeRequired() && !isMultiTable && !optional;
|
|
||||||
|
|
||||||
final EntityQuerySpaceImpl rhs = new EntityQuerySpaceImpl(
|
|
||||||
persister,
|
|
||||||
querySpaceUid,
|
|
||||||
getQuerySpaces(),
|
|
||||||
required,
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
getQuerySpaces().registerQuerySpace( rhs );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createEntityJoin(
|
|
||||||
this,
|
|
||||||
attribute.getName(),
|
|
||||||
rhs,
|
|
||||||
required,
|
|
||||||
(EntityType) attribute.getType(),
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
|
|
||||||
internalGetJoins().add( join );
|
|
||||||
|
|
||||||
return join;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JoinDefinedByMetadata addCollectionJoin(
|
|
||||||
AttributeDefinition attributeDefinition,
|
|
||||||
CollectionPersister collectionPersister,
|
|
||||||
String querySpaceUid) {
|
|
||||||
final boolean required = canJoinsBeRequired() && !attributeDefinition.isNullable();
|
|
||||||
|
|
||||||
final CollectionQuerySpaceImpl rhs = new CollectionQuerySpaceImpl(
|
|
||||||
collectionPersister,
|
|
||||||
querySpaceUid,
|
|
||||||
getQuerySpaces(),
|
|
||||||
required,
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
getQuerySpaces().registerQuerySpace( rhs );
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCollectionJoin(
|
|
||||||
this,
|
|
||||||
attributeDefinition.getName(),
|
|
||||||
rhs,
|
|
||||||
required,
|
|
||||||
(CollectionType) attributeDefinition.getType(),
|
|
||||||
sessionFactory()
|
|
||||||
);
|
|
||||||
internalGetJoins().add( join );
|
|
||||||
|
|
||||||
return join;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JoinDefinedByMetadata makeCompositeIdentifierJoin() {
|
|
||||||
final String compositeQuerySpaceUid = getUid() + "-id";
|
final String compositeQuerySpaceUid = getUid() + "-id";
|
||||||
final CompositeQuerySpaceImpl rhs = new CompositeQuerySpaceImpl(
|
final ExpandingCompositeQuerySpace rhs = getExpandingQuerySpaces().makeCompositeQuerySpace(
|
||||||
this,
|
compositeQuerySpaceUid,
|
||||||
new CompositePropertyMapping(
|
new CompositePropertyMapping(
|
||||||
(CompositeType) getEntityPersister().getIdentifierType(),
|
(CompositeType) getEntityPersister().getIdentifierType(),
|
||||||
(PropertyMapping) getEntityPersister(),
|
(PropertyMapping) getEntityPersister(),
|
||||||
getEntityPersister().getIdentifierPropertyName()
|
getEntityPersister().getIdentifierPropertyName()
|
||||||
),
|
),
|
||||||
compositeQuerySpaceUid,
|
|
||||||
canJoinsBeRequired()
|
canJoinsBeRequired()
|
||||||
);
|
);
|
||||||
getQuerySpaces().registerQuerySpace( rhs );
|
|
||||||
|
|
||||||
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
final JoinDefinedByMetadata join = JoinHelper.INSTANCE.createCompositeJoin(
|
||||||
this,
|
this,
|
||||||
EntityPersister.ENTITY_ID,
|
EntityPersister.ENTITY_ID,
|
||||||
|
@ -184,6 +86,6 @@ public class EntityQuerySpaceImpl extends AbstractQuerySpace implements Expandin
|
||||||
);
|
);
|
||||||
internalGetJoins().add( join );
|
internalGetJoins().add( join );
|
||||||
|
|
||||||
return join;
|
return rhs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,9 +32,10 @@ import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.internal.CoreLogging;
|
import org.hibernate.internal.CoreLogging;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingCollectionQuerySpace;
|
||||||
|
import org.hibernate.loader.plan2.build.spi.ExpandingCompositeQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
import org.hibernate.loader.plan2.build.spi.ExpandingEntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
import org.hibernate.loader.plan2.build.spi.ExpandingQuerySpaces;
|
||||||
import org.hibernate.loader.plan2.spi.CollectionQuerySpace;
|
|
||||||
import org.hibernate.loader.plan2.spi.QuerySpace;
|
import org.hibernate.loader.plan2.spi.QuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.QuerySpaceUidNotRegisteredException;
|
import org.hibernate.loader.plan2.spi.QuerySpaceUidNotRegisteredException;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
|
@ -86,49 +87,91 @@ public class QuerySpacesImpl implements ExpandingQuerySpaces {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ExpandingEntityQuerySpace makeEntityQuerySpace(String uid, EntityPersister entityPersister) {
|
public ExpandingEntityQuerySpace makeRootEntityQuerySpace(String uid, EntityPersister entityPersister) {
|
||||||
if ( querySpaceByUid.containsKey( uid ) ) {
|
final ExpandingEntityQuerySpace space = makeEntityQuerySpace( uid, entityPersister, true );
|
||||||
throw new IllegalStateException( "Encountered duplicate QuerySpace uid : " + uid );
|
roots.add( space );
|
||||||
}
|
return space;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExpandingEntityQuerySpace makeEntityQuerySpace(
|
||||||
|
String uid,
|
||||||
|
EntityPersister entityPersister,
|
||||||
|
boolean canJoinsBeRequired) {
|
||||||
|
|
||||||
|
checkQuerySpaceDoesNotExist( uid );
|
||||||
|
|
||||||
final EntityQuerySpaceImpl space = new EntityQuerySpaceImpl(
|
final EntityQuerySpaceImpl space = new EntityQuerySpaceImpl(
|
||||||
entityPersister,
|
entityPersister,
|
||||||
uid,
|
uid,
|
||||||
this,
|
this,
|
||||||
true,
|
canJoinsBeRequired,
|
||||||
sessionFactory
|
sessionFactory
|
||||||
);
|
);
|
||||||
registerQuerySpace( space );
|
registerQuerySpace( space );
|
||||||
roots.add( space );
|
|
||||||
|
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CollectionQuerySpace makeCollectionQuerySpace(String uid, CollectionPersister collectionPersister) {
|
public ExpandingCollectionQuerySpace makeRootCollectionQuerySpace(String uid, CollectionPersister collectionPersister) {
|
||||||
if ( querySpaceByUid.containsKey( uid ) ) {
|
final ExpandingCollectionQuerySpace space = makeCollectionQuerySpace( uid, collectionPersister, true );
|
||||||
throw new IllegalStateException( "Encountered duplicate QuerySpace uid : " + uid );
|
roots.add( space );
|
||||||
}
|
return space;
|
||||||
|
}
|
||||||
|
|
||||||
final CollectionQuerySpaceImpl space = new CollectionQuerySpaceImpl(
|
@Override
|
||||||
|
public ExpandingCollectionQuerySpace makeCollectionQuerySpace(
|
||||||
|
String uid,
|
||||||
|
CollectionPersister collectionPersister,
|
||||||
|
boolean canJoinsBeRequired) {
|
||||||
|
|
||||||
|
checkQuerySpaceDoesNotExist( uid );
|
||||||
|
|
||||||
|
final ExpandingCollectionQuerySpace space = new CollectionQuerySpaceImpl(
|
||||||
collectionPersister,
|
collectionPersister,
|
||||||
uid,
|
uid,
|
||||||
this,
|
this,
|
||||||
true,
|
canJoinsBeRequired,
|
||||||
sessionFactory
|
sessionFactory
|
||||||
);
|
);
|
||||||
registerQuerySpace( space );
|
registerQuerySpace( space );
|
||||||
roots.add( space );
|
|
||||||
|
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ExpandingCompositeQuerySpace makeCompositeQuerySpace(
|
||||||
|
String uid,
|
||||||
|
CompositePropertyMapping compositePropertyMapping,
|
||||||
|
boolean canJoinsBeRequired) {
|
||||||
|
|
||||||
|
checkQuerySpaceDoesNotExist( uid );
|
||||||
|
|
||||||
|
final ExpandingCompositeQuerySpace space = new CompositeQuerySpaceImpl(
|
||||||
|
compositePropertyMapping,
|
||||||
|
uid,
|
||||||
|
this,
|
||||||
|
canJoinsBeRequired,
|
||||||
|
sessionFactory
|
||||||
|
);
|
||||||
|
registerQuerySpace( space );
|
||||||
|
|
||||||
|
return space;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkQuerySpaceDoesNotExist(String uid) {
|
||||||
|
if ( querySpaceByUid.containsKey( uid ) ) {
|
||||||
|
throw new IllegalStateException( "Encountered duplicate QuerySpace uid : " + uid );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Feeds a QuerySpace into this spaces group.
|
* Feeds a QuerySpace into this spaces group.
|
||||||
*
|
*
|
||||||
* @param querySpace The space
|
* @param querySpace The space
|
||||||
*/
|
*/
|
||||||
public void registerQuerySpace(QuerySpace querySpace) {
|
private void registerQuerySpace(QuerySpace querySpace) {
|
||||||
log.debugf(
|
log.debugf(
|
||||||
"Adding QuerySpace : uid = %s -> %s]",
|
"Adding QuerySpace : uid = %s -> %s]",
|
||||||
querySpace.getUid(),
|
querySpace.getUid(),
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.jboss.logging.MDC;
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
import org.hibernate.engine.FetchStrategy;
|
import org.hibernate.engine.FetchStrategy;
|
||||||
import org.hibernate.engine.FetchStyle;
|
import org.hibernate.engine.FetchStyle;
|
||||||
|
import org.hibernate.engine.FetchTiming;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
import org.hibernate.loader.PropertyPath;
|
import org.hibernate.loader.PropertyPath;
|
||||||
|
@ -184,7 +185,7 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
||||||
throw new HibernateException( "This strategy does not support root entity returns" );
|
throw new HibernateException( "This strategy does not support root entity returns" );
|
||||||
}
|
}
|
||||||
|
|
||||||
final EntityReturnImpl entityReturn = new EntityReturnImpl( entityDefinition, this );
|
final EntityReturnImpl entityReturn = new EntityReturnImpl( entityDefinition, querySpaces );
|
||||||
addRootReturn( entityReturn );
|
addRootReturn( entityReturn );
|
||||||
pushToStack( entityReturn );
|
pushToStack( entityReturn );
|
||||||
|
|
||||||
|
@ -335,7 +336,7 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
||||||
throw new HibernateException( "This strategy does not support root collection returns" );
|
throw new HibernateException( "This strategy does not support root collection returns" );
|
||||||
}
|
}
|
||||||
|
|
||||||
final CollectionReturn collectionReturn = new CollectionReturnImpl( collectionDefinition, this );
|
final CollectionReturn collectionReturn = new CollectionReturnImpl( collectionDefinition, querySpaces );
|
||||||
pushToCollectionStack( collectionReturn );
|
pushToCollectionStack( collectionReturn );
|
||||||
addRootReturn( collectionReturn );
|
addRootReturn( collectionReturn );
|
||||||
|
|
||||||
|
@ -515,7 +516,7 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
||||||
throw new HibernateException( "A component cannot be the root of a walk nor a graph" );
|
throw new HibernateException( "A component cannot be the root of a walk nor a graph" );
|
||||||
}
|
}
|
||||||
|
|
||||||
final CompositeFetch compositeFetch = currentSource().buildCompositeFetch( compositionDefinition, this );
|
final CompositeFetch compositeFetch = currentSource().buildCompositeFetch( compositionDefinition );
|
||||||
pushToStack( (ExpandingFetchSource) compositeFetch );
|
pushToStack( (ExpandingFetchSource) compositeFetch );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,8 +623,7 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
||||||
currentSource().buildBidirectionalEntityReference(
|
currentSource().buildBidirectionalEntityReference(
|
||||||
attributeDefinition,
|
attributeDefinition,
|
||||||
fetchStrategy,
|
fetchStrategy,
|
||||||
registeredFetchSource( associationKey ).resolveEntityReference(),
|
registeredFetchSource( associationKey ).resolveEntityReference()
|
||||||
this
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -786,12 +786,9 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
||||||
protected boolean handleAssociationAttribute(AssociationAttributeDefinition attributeDefinition) {
|
protected boolean handleAssociationAttribute(AssociationAttributeDefinition attributeDefinition) {
|
||||||
// todo : this seems to not be correct for one-to-one
|
// todo : this seems to not be correct for one-to-one
|
||||||
final FetchStrategy fetchStrategy = determineFetchStrategy( attributeDefinition );
|
final FetchStrategy fetchStrategy = determineFetchStrategy( attributeDefinition );
|
||||||
if ( fetchStrategy.getStyle() != FetchStyle.JOIN ) {
|
if ( fetchStrategy.getTiming() != FetchTiming.IMMEDIATE ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// if ( fetchStrategy.getTiming() != FetchTiming.IMMEDIATE ) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
|
|
||||||
final ExpandingFetchSource currentSource = currentSource();
|
final ExpandingFetchSource currentSource = currentSource();
|
||||||
currentSource.validateFetchPlan( fetchStrategy, attributeDefinition );
|
currentSource.validateFetchPlan( fetchStrategy, attributeDefinition );
|
||||||
|
@ -804,14 +801,13 @@ public abstract class AbstractLoadPlanBuildingAssociationVisitationStrategy
|
||||||
if ( nature == AssociationAttributeDefinition.AssociationNature.ENTITY ) {
|
if ( nature == AssociationAttributeDefinition.AssociationNature.ENTITY ) {
|
||||||
EntityFetch fetch = currentSource.buildEntityFetch(
|
EntityFetch fetch = currentSource.buildEntityFetch(
|
||||||
attributeDefinition,
|
attributeDefinition,
|
||||||
fetchStrategy,
|
fetchStrategy
|
||||||
this
|
|
||||||
);
|
);
|
||||||
pushToStack( (ExpandingFetchSource) fetch );
|
pushToStack( (ExpandingFetchSource) fetch );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Collection
|
// Collection
|
||||||
CollectionFetch fetch = currentSource.buildCollectionFetch( attributeDefinition, fetchStrategy, this );
|
CollectionFetch fetch = currentSource.buildCollectionFetch( attributeDefinition, fetchStrategy );
|
||||||
pushToCollectionStack( fetch );
|
pushToCollectionStack( fetch );
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013, Red Hat Inc. or third-party contributors as
|
||||||
|
* indicated by the @author tags or express copyright attribution
|
||||||
|
* statements applied by the authors. All third-party contributions are
|
||||||
|
* distributed under license by Red Hat Inc.
|
||||||
|
*
|
||||||
|
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||||
|
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||||
|
* Lesser General Public License, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this distribution; if not, write to:
|
||||||
|
* Free Software Foundation, Inc.
|
||||||
|
* 51 Franklin Street, Fifth Floor
|
||||||
|
* Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
|
package org.hibernate.loader.plan2.build.spi;
|
||||||
|
|
||||||
|
import org.hibernate.loader.plan2.spi.CollectionQuerySpace;
|
||||||
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
import org.hibernate.type.CompositeType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Gail Badner
|
||||||
|
*/
|
||||||
|
public interface ExpandingCollectionQuerySpace extends CollectionQuerySpace {
|
||||||
|
|
||||||
|
public ExpandingEntityQuerySpace addIndexEntityQuerySpace(final EntityPersister elementPersister);
|
||||||
|
|
||||||
|
public ExpandingCompositeQuerySpace addIndexCompositeQuerySpace(CompositeType compositeType);
|
||||||
|
|
||||||
|
public ExpandingEntityQuerySpace addElementEntityQuerySpace(
|
||||||
|
final EntityPersister elementPersister);
|
||||||
|
|
||||||
|
public ExpandingCompositeQuerySpace addElementCompositeQuerySpace(
|
||||||
|
CompositeType compositeType);
|
||||||
|
}
|
|
@ -28,5 +28,5 @@ import org.hibernate.loader.plan2.spi.CompositeQuerySpace;
|
||||||
/**
|
/**
|
||||||
* @author Gail Badner
|
* @author Gail Badner
|
||||||
*/
|
*/
|
||||||
public interface ExpandingCompositeQuerySpace extends CompositeQuerySpace, ExpandingQuerySpace {
|
public interface ExpandingCompositeQuerySpace extends CompositeQuerySpace, ExpandingSourceQuerySpace {
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,10 @@
|
||||||
package org.hibernate.loader.plan2.build.spi;
|
package org.hibernate.loader.plan2.build.spi;
|
||||||
|
|
||||||
import org.hibernate.loader.plan2.spi.EntityQuerySpace;
|
import org.hibernate.loader.plan2.spi.EntityQuerySpace;
|
||||||
import org.hibernate.loader.plan2.spi.Join;
|
|
||||||
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface ExpandingEntityQuerySpace extends EntityQuerySpace, ExpandingQuerySpace {
|
public interface ExpandingEntityQuerySpace extends EntityQuerySpace, ExpandingSourceQuerySpace {
|
||||||
public JoinDefinedByMetadata makeCompositeIdentifierJoin();
|
public ExpandingCompositeQuerySpace makeCompositeIdentifierQuerySpace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,22 +51,18 @@ public interface ExpandingFetchSource extends FetchSource {
|
||||||
|
|
||||||
public EntityFetch buildEntityFetch(
|
public EntityFetch buildEntityFetch(
|
||||||
AssociationAttributeDefinition attributeDefinition,
|
AssociationAttributeDefinition attributeDefinition,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy);
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext);
|
|
||||||
|
|
||||||
public BidirectionalEntityReference buildBidirectionalEntityReference(
|
public BidirectionalEntityReference buildBidirectionalEntityReference(
|
||||||
AssociationAttributeDefinition attributeDefinition,
|
AssociationAttributeDefinition attributeDefinition,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy,
|
||||||
EntityReference targetEntityReference,
|
EntityReference targetEntityReference);
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext);
|
|
||||||
|
|
||||||
public CompositeFetch buildCompositeFetch(
|
public CompositeFetch buildCompositeFetch(
|
||||||
CompositionDefinition attributeDefinition,
|
CompositionDefinition attributeDefinition);
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext);
|
|
||||||
|
|
||||||
public CollectionFetch buildCollectionFetch(
|
public CollectionFetch buildCollectionFetch(
|
||||||
AssociationAttributeDefinition attributeDefinition,
|
AssociationAttributeDefinition attributeDefinition,
|
||||||
FetchStrategy fetchStrategy,
|
FetchStrategy fetchStrategy);
|
||||||
LoadPlanBuildingContext loadPlanBuildingContext);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.loader.plan2.build.spi;
|
package org.hibernate.loader.plan2.build.spi;
|
||||||
|
|
||||||
import org.hibernate.loader.plan2.spi.CollectionQuerySpace;
|
import org.hibernate.loader.plan2.build.internal.spaces.CompositePropertyMapping;
|
||||||
import org.hibernate.loader.plan2.spi.QuerySpaces;
|
import org.hibernate.loader.plan2.spi.QuerySpaces;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
@ -34,7 +34,26 @@ import org.hibernate.persister.entity.EntityPersister;
|
||||||
public interface ExpandingQuerySpaces extends QuerySpaces {
|
public interface ExpandingQuerySpaces extends QuerySpaces {
|
||||||
public String generateImplicitUid();
|
public String generateImplicitUid();
|
||||||
|
|
||||||
public ExpandingEntityQuerySpace makeEntityQuerySpace(String uid, EntityPersister entityPersister);
|
public ExpandingEntityQuerySpace makeRootEntityQuerySpace(
|
||||||
|
String uid,
|
||||||
|
EntityPersister entityPersister);
|
||||||
|
|
||||||
public CollectionQuerySpace makeCollectionQuerySpace(String uid, CollectionPersister collectionPersister);
|
public ExpandingEntityQuerySpace makeEntityQuerySpace(
|
||||||
|
String uid,
|
||||||
|
EntityPersister entityPersister,
|
||||||
|
boolean canJoinsBeRequired);
|
||||||
|
|
||||||
|
public ExpandingCollectionQuerySpace makeRootCollectionQuerySpace(
|
||||||
|
String uid,
|
||||||
|
CollectionPersister collectionPersister);
|
||||||
|
|
||||||
|
public ExpandingCollectionQuerySpace makeCollectionQuerySpace(
|
||||||
|
String uid,
|
||||||
|
CollectionPersister collectionPersister,
|
||||||
|
boolean canJoinsBeRequired);
|
||||||
|
|
||||||
|
public ExpandingCompositeQuerySpace makeCompositeQuerySpace(
|
||||||
|
String uid,
|
||||||
|
CompositePropertyMapping compositePropertyMapping,
|
||||||
|
boolean canJoinsBeRequired);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.loader.plan2.build.spi;
|
package org.hibernate.loader.plan2.build.spi;
|
||||||
|
|
||||||
import org.hibernate.loader.plan2.spi.JoinDefinedByMetadata;
|
|
||||||
import org.hibernate.loader.plan2.spi.QuerySpace;
|
import org.hibernate.loader.plan2.spi.QuerySpace;
|
||||||
import org.hibernate.persister.collection.CollectionPersister;
|
import org.hibernate.persister.collection.CollectionPersister;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
|
@ -33,20 +32,25 @@ import org.hibernate.persister.walking.spi.CompositionDefinition;
|
||||||
/**
|
/**
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface ExpandingQuerySpace extends QuerySpace {
|
public interface ExpandingSourceQuerySpace extends QuerySpace {
|
||||||
|
|
||||||
public JoinDefinedByMetadata addCompositeJoin(
|
public ExpandingCompositeQuerySpace addCompositeQuerySpace(
|
||||||
CompositionDefinition compositionDefinition,
|
CompositionDefinition compositionDefinition,
|
||||||
String querySpaceUid);
|
String querySpaceUid,
|
||||||
|
boolean shouldIncludeJoin);
|
||||||
|
|
||||||
public JoinDefinedByMetadata addEntityJoin(
|
public ExpandingEntityQuerySpace addEntityQuerySpace(
|
||||||
AttributeDefinition attributeDefinition,
|
AttributeDefinition attributeDefinition,
|
||||||
EntityPersister persister,
|
EntityPersister persister,
|
||||||
String querySpaceUid,
|
String querySpaceUid,
|
||||||
boolean optional);
|
boolean optional,
|
||||||
|
boolean shouldIncludeJoin);
|
||||||
|
|
||||||
public JoinDefinedByMetadata addCollectionJoin(
|
public ExpandingCollectionQuerySpace addCollectionQuerySpace(
|
||||||
AttributeDefinition attributeDefinition,
|
AttributeDefinition attributeDefinition,
|
||||||
CollectionPersister collectionPersister,
|
CollectionPersister collectionPersister,
|
||||||
String querySpaceUid);
|
String querySpaceUid,
|
||||||
|
boolean shouldIncludeJoin);
|
||||||
|
|
||||||
|
public ExpandingQuerySpaces getExpandingQuerySpaces();
|
||||||
}
|
}
|
Loading…
Reference in New Issue