Java 类org.hibernate.ogm.model.spi.Association 实例源码

项目:hibernate-ogm-redis    文件:RedisHashDialect.java   
@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;
}
项目:hibernate-ogm-redis    文件:RedisHashDialect.java   
@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
            )
    );
}
项目:hibernate-ogm-redis    文件:RedisHashDialect.java   
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;
}
项目:hibernate-ogm-ignite    文件:IgniteDialect.java   
@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() );
    }
}
项目:lightblue-hibernate-ogm    文件:LightblueDialect.java   
@Override
public Association getAssociation(AssociationKey key, AssociationContext associationContext) {
    throw new UnsupportedOperationException("not yet supported");
}
项目:lightblue-hibernate-ogm    文件:LightblueDialect.java   
@Override
public Association createAssociation(AssociationKey key, AssociationContext associationContext) {
    throw new UnsupportedOperationException("not yet supported");
}
项目:lightblue-hibernate-ogm    文件:LightblueDialect.java   
@Override
public void insertOrUpdateAssociation(AssociationKey key, Association association, AssociationContext associationContext) {
    throw new UnsupportedOperationException("not yet supported");
}