@Override public Association getAssociation( AssociationKey key, AssociationContext associationContext) { RedisAssociation redisAssociation = null; if ( isStoredInEntityStructure( key.getMetadata(), associationContext.getAssociationTypeContext() ) ) { TuplePointer tuplePointer = getEmbeddingEntityTuplePointer( key, associationContext ); if ( tuplePointer == null ) { // The entity associated with this association has already been removed // see ManyToOneTest#testRemovalOfTransientEntityWithAssociation return null; } HashEntity owningEntity = getEntityFromTuple( tuplePointer.getTuple() ); if ( owningEntity != null && owningEntity.has( key.getMetadata().getCollectionRole() ) ) { redisAssociation = RedisAssociation.fromHashEmbeddedAssociation( tuplePointer, key.getMetadata() ); } } else { org.hibernate.ogm.datastore.redis.dialect.value.Association association = getAssociation( key ); if ( association == null ) { return null; } redisAssociation = RedisAssociation.fromAssociationDocument( association ); } return redisAssociation != null ? new org.hibernate.ogm.model.spi.Association( new RedisAssociationSnapshot( redisAssociation, key ) ) : null; }
@Override public Association createAssociation( AssociationKey key, AssociationContext associationContext) { RedisAssociation redisAssociation; if ( isStoredInEntityStructure( key.getMetadata(), associationContext.getAssociationTypeContext() ) ) { TuplePointer tuplePointer = getEmbeddingEntityTuplePointer( key, associationContext ); HashEntity owningEntity = getEntityFromTuple( tuplePointer.getTuple() ); if ( owningEntity == null ) { owningEntity = new HashEntity( new HashMap<String, String>() ); storeEntity( key.getEntityKey(), owningEntity, associationContext.getAssociationTypeContext().getHostingEntityOptionsContext() ); tuplePointer.setTuple( new Tuple( new RedisHashTupleSnapshot( owningEntity ), SnapshotType.UPDATE ) ); } redisAssociation = RedisAssociation.fromHashEmbeddedAssociation( tuplePointer, key.getMetadata() ); } else { redisAssociation = RedisAssociation.fromAssociationDocument( new org.hibernate.ogm.datastore.redis.dialect.value.Association() ); } return new org.hibernate.ogm.model.spi.Association( new RedisAssociationSnapshot( redisAssociation, key ) ); }
private Object getAssociationRows( Association association, AssociationKey key) { List<Object> rows = new ArrayList<>( association.size() ); for ( RowKey rowKey : association.getKeys() ) { rows.add( getAssociationRow( association.get( rowKey ), key ) ); } return rows; }
@Override public Association createAssociation(AssociationKey key, AssociationContext associationContext) { if ( key.getMetadata().getAssociationKind() == AssociationKind.ASSOCIATION ) { return new Association( new IgniteAssociationSnapshot( key ) ); } else if ( key.getMetadata().getAssociationKind() == AssociationKind.EMBEDDED_COLLECTION ) { return new Association( new IgniteEmbeddedAssociationSnapshot( key, associationContext.getEntityTuplePointer().getTuple() ) ); } else { throw new UnsupportedOperationException( "Unknown association kind " + key.getMetadata().getAssociationKind() ); } }
@Override public Association getAssociation(AssociationKey key, AssociationContext associationContext) { throw new UnsupportedOperationException("not yet supported"); }
@Override public Association createAssociation(AssociationKey key, AssociationContext associationContext) { throw new UnsupportedOperationException("not yet supported"); }
@Override public void insertOrUpdateAssociation(AssociationKey key, Association association, AssociationContext associationContext) { throw new UnsupportedOperationException("not yet supported"); }