// if we get here, it is a root
if ( ! supportsRootCollectionReturns() ) {
throw new HibernateException( "This strategy does not support root collection returns" );
}
final CollectionReturn collectionReturn = new CollectionReturnImpl( collectionDefinition, this );
pushToCollectionStack( collectionReturn );
addRootReturn( collectionReturn );
// also add an AssociationKey for the root so we can later on recognize circular references back to the root.
// for a collection, the circularity would always be to an entity element...
if ( collectionReturn.getElementGraph() != null ) {
if ( EntityReference.class.isInstance( collectionReturn.getElementGraph() ) ) {
final EntityReference entityReference = (EntityReference) collectionReturn.getElementGraph();
final Joinable entityPersister = (Joinable) entityReference.getEntityPersister();
associationKeyRegistered(
new AssociationKey( entityPersister.getTableName(), entityPersister.getKeyColumnNames() )
);
}