Java 类org.hibernate.ogm.datastore.document.options.AssociationStorageType 实例源码

项目:hibernate-ogm-redis    文件:TTLConfiguredProgrammaticallyTest.java   
@Test
public void ttlOnPropertyLevel() throws Exception {
    Map<String, Object> settings = new HashMap<String, Object>();

    TestHelper.configureOptionsFor( settings, Redis.class )
            .associationStorage( AssociationStorageType.ASSOCIATION_DOCUMENT )
            .entity( Cloud.class )
            .property( "backupSnowFlakes", ElementType.METHOD )
            .ttl( 1, TimeUnit.DAYS );

    setupSessionFactory( settings );
    createCloudWithTwoProducedAndOneBackupSnowflake();

    // property-level options are applied to the type as well.
    // not sure, whether this is a good idea.
    assertThat( cloudTtl() ).isGreaterThan( TimeUnit.HOURS.toMillis( 23 ) )
            .isLessThanOrEqualTo( TimeUnit.HOURS.toMillis( 24 ) );

    assertThat( associationTtl() ).isGreaterThan( TimeUnit.HOURS.toMillis( 23 ) )
            .isLessThanOrEqualTo( TimeUnit.HOURS.toMillis( 24 ) );
}
项目:hibernate-ogm-ignite    文件:IgniteTestHelper.java   
@Override
public long getNumberOfAssociations(SessionFactory sessionFactory, AssociationStorageType type) {
    int asscociationCount = 0;
    Set<IgniteCache<Object, BinaryObject>> processedCaches = Collections.newSetFromMap( new IdentityHashMap<IgniteCache<Object, BinaryObject>, Boolean>() );

    for ( CollectionPersister collectionPersister : ( (SessionFactoryImplementor) sessionFactory ).getCollectionPersisters().values() ) {
        AssociationKeyMetadata associationKeyMetadata = ( (OgmCollectionPersister) collectionPersister ).getAssociationKeyMetadata();
        IgniteCache<Object, BinaryObject> associationCache = getAssociationCache( sessionFactory, associationKeyMetadata );
        if ( !processedCaches.contains( associationCache ) ) {
            asscociationCount += associationCache.size();
            processedCaches.add( associationCache );
        }
    }

    return asscociationCount;
}
项目:hibernate-ogm-redis    文件:RedisJsonDialect.java   
@Override
public boolean isStoredInEntityStructure(
        AssociationKeyMetadata keyMetadata,
        AssociationTypeContext associationTypeContext) {

    AssociationStorageType associationStorage = getAssociationStorageType( associationTypeContext );

    if ( keyMetadata.getAssociationType() == AssociationType.ONE_TO_ONE || keyMetadata.getAssociationKind() == AssociationKind.EMBEDDED_COLLECTION || associationStorage == AssociationStorageType.IN_ENTITY ) {
        return true;
    }

    return false;
}
项目:hibernate-ogm-redis    文件:RedisTestHelper.java   
@Override
public long getNumberOfAssociations(SessionFactory sessionFactory, AssociationStorageType type) {
    switch ( type ) {
        case ASSOCIATION_DOCUMENT:
            return getNumberOfGlobalAssociations( sessionFactory );
        case IN_ENTITY:
            return getNumberOfEmbeddedAssociations( sessionFactory );
        default:
            throw new IllegalArgumentException( "Unexpected association storaget type " + type );
    }
}
项目:hibernate-ogm-redis    文件:GlobalPropertyTTLTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.ASSOCIATION_DOCUMENT
    );
}
项目:hibernate-ogm-redis    文件:RedisTTLTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.ASSOCIATION_DOCUMENT
    );
}
项目:hibernate-ogm-redis    文件:ListGlobalTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.ASSOCIATION_DOCUMENT
    );
}
项目:hibernate-ogm-redis    文件:ManyToOneGlobalTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.ASSOCIATION_DOCUMENT
    );
}
项目:hibernate-ogm-redis    文件:ManyToManyDocumentTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.ASSOCIATION_DOCUMENT
    );
}
项目:hibernate-ogm-redis    文件:ManyToManyInEntityTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.IN_ENTITY
    );
}
项目:hibernate-ogm-redis    文件:OneToOneInEntityTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.IN_ENTITY
    );
}
项目:hibernate-ogm-redis    文件:CollectionUnidirectionalInEntityTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.IN_ENTITY
    );
}
项目:hibernate-ogm-redis    文件:ManyToOneInEntityTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.IN_ENTITY
    );
}
项目:hibernate-ogm-redis    文件:OneToOneCollectionTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.ASSOCIATION_DOCUMENT
    );
}
项目:hibernate-ogm-redis    文件:ManyToManyGlobalTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.ASSOCIATION_DOCUMENT
    );
}
项目:hibernate-ogm-redis    文件:ManyToOneInEntityJsonRepresentationTest.java   
@Override
protected void configure(Map<String, Object> cfg) {
    super.configure( cfg );
    cfg.put(
            DocumentStoreProperties.ASSOCIATIONS_STORE,
            AssociationStorageType.IN_ENTITY
    );
}
项目:hibernate-ogm-redis    文件:RedisPropertyContextImpl.java   
@Override
public RedisPropertyContext associationStorage(AssociationStorageType associationStorageType) {
    Contracts.assertParameterNotNull( associationStorageType, "associationStorageType" );
    addPropertyOption( new AssociationStorageOption(), associationStorageType );
    return this;
}
项目:hibernate-ogm-redis    文件:RedisEntityContextImpl.java   
@Override
public RedisEntityContext associationStorage(AssociationStorageType associationStorageType) {
    Contracts.assertParameterNotNull( associationStorageType, "associationStorageType" );
    addEntityOption( new AssociationStorageOption(), associationStorageType );
    return this;
}
项目:hibernate-ogm-redis    文件:RedisGlobalContextImpl.java   
@Override
public RedisGlobalContext associationStorage(AssociationStorageType associationStorageType) {
    Contracts.assertParameterNotNull( associationStorageType, "associationStorageType" );
    addGlobalOption( new AssociationStorageOption(), associationStorageType );
    return this;
}
项目:hibernate-ogm-redis    文件:RedisJsonDialect.java   
private AssociationStorageType getAssociationStorageType(AssociationTypeContext associationTypeContext) {
    return associationTypeContext.getOptionsContext().getUnique(
            AssociationStorageOption.class
    );
}
项目:hibernate-ogm-redis    文件:CompositeIdInEmbeddedTest.java   
@Override
protected void configure(GetterPersistenceUnitInfo info) {
    super.configure( info );
    info.getProperties()
            .put( DocumentStoreProperties.ASSOCIATIONS_STORE, AssociationStorageType.IN_ENTITY );
}