private TupleAsMapResultSet getResultSet(Serializable id, SessionImplementor session) {
//TODO this if won't work when we will support collections inside the entity tuple but that will do for now
final TupleAsMapResultSet resultset = new TupleAsMapResultSet();
if ( getEntityPersisters().length > 0 ) {
OgmEntityPersister persister = getEntityPersisters()[0];
final EntityKey key = EntityKeyBuilder.fromPersister( persister, id, session );
Tuple entry = gridDialect.getTuple( key, persister.getTupleContext() );
if ( entry != null ) {
resultset.addTuple( entry );
}
}
else {
//collection persister
if ( getCollectionPersisters().length != 1 ) {
throw new AssertionFailure( "Found an unexpected number of collection persisters: " + getCollectionPersisters().length );
}
final OgmCollectionPersister persister = (OgmCollectionPersister) getCollectionPersisters()[0];
PropertyMetadataProvider metadataProvider = new PropertyMetadataProvider()
.gridDialect(gridDialect)
.tableName(persister.getTableName())
.key( id )
.keyColumnNames( persister.getKeyColumnNames() )
.keyGridType( persister.getKeyGridType() )
.collectionPersister( persister )
.session( session );
Association assoc = metadataProvider.getCollectionMetadataOrNull();
if ( assoc != null ) {
for ( RowKey rowKey : assoc.getKeys() ) {