public OgmCollectionPersister(final Collection collection, final CollectionRegionAccessStrategy cacheAccessStrategy, final Configuration cfg, final SessionFactoryImplementor factory)
throws MappingException, CacheException {
super( collection, cacheAccessStrategy, cfg, factory );
ServiceRegistry registry = factory.getServiceRegistry();
final TypeTranslator typeTranslator = registry.getService( TypeTranslator.class );
this.gridDialect = registry.getService( DatastoreServices.class ).getGridDialect();
keyGridType = typeTranslator.getType( getKeyType() );
elementGridType = typeTranslator.getType( getElementType() );
indexGridType = typeTranslator.getType( getIndexType() );
identifierGridType = typeTranslator.getType( getIdentifierType() );
// copied from the superclass constructor
isInverse = collection.isInverse();
oneToMany = collection.isOneToMany();
if ( collection.isOneToMany() && getElementPersister() != null && getElementType().isEntityType() ) {
associationType = AssociationType.EMBEDDED_FK_TO_ENTITY;
final Type identifierOrUniqueKeyType = ( (EntityType) getElementType() )
.getIdentifierOrUniqueKeyType( factory );
gridTypeOfAssociatedId = typeTranslator.getType( identifierOrUniqueKeyType );
}
else if ( collection.isOneToMany() ) {
// one to many but not what we expected
throw new AssertionFailure( "Association marked as one to many but has no ManyToOneType: " + collection.getRole() );
}
else if ( getElementType().isAssociationType() && getElementType().isEntityType() ) {
associationType = AssociationType.ASSOCIATION_TABLE_TO_ENTITY;
final Type identifierOrUniqueKeyType = ( (EntityType) getElementType() ).getIdentifierOrUniqueKeyType( factory );
gridTypeOfAssociatedId = typeTranslator.getType( identifierOrUniqueKeyType );
}
else {
gridTypeOfAssociatedId = null;
associationType = AssociationType.OTHER;
}