HHH-8276 - Integrate LoadPlans into UniqueEntityLoader (PoC)

This commit is contained in:
Strong Liu 2013-09-16 15:17:16 +08:00 committed by Steve Ebersole
parent 77d7deb0f3
commit c607e30051
4 changed files with 53 additions and 16 deletions

View File

@ -1831,12 +1831,12 @@ public abstract class AbstractCollectionPersister
}
}
catch ( SQLException sqle ) {
throw getFactory().getSQLExceptionHelper().convert(
throw getSQLExceptionHelper().convert(
sqle,
"could not retrieve collection size: " +
MessageHelper.collectionInfoString( this, key, getFactory() ),
sqlSelectSizeString
);
);
}
}
@ -1873,12 +1873,12 @@ public abstract class AbstractCollectionPersister
}
}
catch ( SQLException sqle ) {
throw getFactory().getSQLExceptionHelper().convert(
throw getSQLExceptionHelper().convert(
sqle,
"could not check row existence: " +
MessageHelper.collectionInfoString( this, key, getFactory() ),
sqlSelectSizeString
);
);
}
}
@ -1909,12 +1909,12 @@ public abstract class AbstractCollectionPersister
}
}
catch ( SQLException sqle ) {
throw getFactory().getSQLExceptionHelper().convert(
throw getSQLExceptionHelper().convert(
sqle,
"could not read row: " +
MessageHelper.collectionInfoString( this, key, getFactory() ),
sqlSelectSizeString
);
);
}
}
@ -2002,8 +2002,38 @@ public abstract class AbstractCollectionPersister
if ( ! getType().isComponentType() ) {
throw new IllegalStateException( "Cannot treat entity collection index type as composite" );
}
// todo : implement
throw new NotYetImplementedException();
return new CompositeCollectionElementDefinition() {
@Override
public String getName() {
return "index";
}
@Override
public CompositeType getType() {
return (CompositeType) getIndexType();
}
@Override
public boolean isNullable() {
return false;
}
@Override
public AttributeSource getSource() {
// TODO: what if this is a collection w/in an encapsulated composition attribute?
// should return the encapsulated composition attribute instead???
return getOwnerEntityPersister();
}
@Override
public Iterable<AttributeDefinition> getAttributes() {
return CompositionSingularSubAttributesHelper.getCompositeCollectionIndexSubAttributes( this );
}
@Override
public CollectionDefinition getCollectionDefinition() {
return AbstractCollectionPersister.this;
}
};
}
};
}

View File

@ -100,6 +100,18 @@ public class CompositionSingularSubAttributesHelper {
);
}
public static Iterable<AttributeDefinition> getCompositeCollectionIndexSubAttributes(CompositeCollectionElementDefinition compositionElementDefinition){
final QueryableCollection collectionPersister =
(QueryableCollection) compositionElementDefinition.getCollectionDefinition().getCollectionPersister();
return getSingularSubAttributes(
compositionElementDefinition.getSource(),
(OuterJoinLoadable) collectionPersister.getOwnerEntityPersister(),
(CompositeType) collectionPersister.getIndexType(),
collectionPersister.getTableName(),
collectionPersister.getIndexColumnNames()
);
}
private static Iterable<AttributeDefinition> getSingularSubAttributes(
final AttributeSource source,
final OuterJoinLoadable ownerEntityPersister,

View File

@ -156,9 +156,7 @@ public abstract class AbstractCompositionAttribute extends AbstractNonIdentifier
}
final CompositeType cType = getType();
final boolean nullable = cType.getPropertyNullability() == null
? true
: cType.getPropertyNullability()[ subAttributeNumber ];
final boolean nullable = cType.getPropertyNullability() == null || cType.getPropertyNullability()[subAttributeNumber];
return new CompositeBasedAssociationAttribute(
AbstractCompositionAttribute.this,
@ -203,9 +201,7 @@ public abstract class AbstractCompositionAttribute extends AbstractNonIdentifier
}
else {
final CompositeType cType = getType();
final boolean nullable = cType.getPropertyNullability() == null
? true
: cType.getPropertyNullability()[ subAttributeNumber ];
final boolean nullable = cType.getPropertyNullability() == null || cType.getPropertyNullability()[subAttributeNumber];
return new CompositeBasedBasicAttribute(
AbstractCompositionAttribute.this,

View File

@ -32,8 +32,7 @@ import org.hibernate.type.CompositeType;
* @author Steve Ebersole
*/
public class CompositionBasedCompositionAttribute
extends AbstractCompositionAttribute
implements CompositionDefinition {
extends AbstractCompositionAttribute {
public CompositionBasedCompositionAttribute(
CompositionDefinition source,
SessionFactoryImplementor sessionFactory,