Example usage for org.hibernate.cache.cfg.spi EntityDataCachingConfig getVersionComparatorAccess

List of usage examples for org.hibernate.cache.cfg.spi EntityDataCachingConfig getVersionComparatorAccess

Introduction

In this page you can find the example usage for org.hibernate.cache.cfg.spi EntityDataCachingConfig getVersionComparatorAccess.

Prototype

Supplier<Comparator> getVersionComparatorAccess();

Source Link

Document

Access to the comparator to be used with the entity's version.

Usage

From source file:org.infinispan.hibernate.cache.v53.impl.DomainDataRegionImpl.java

License:LGPL

@Override
public EntityDataAccess getEntityDataAccess(NavigableRole rootEntityRole) {
    EntityDataCachingConfig entityConfig = findConfig(config.getEntityCaching(), rootEntityRole);
    AccessType accessType = entityConfig.getAccessType();
    AccessDelegate accessDelegate = createAccessDelegate(accessType,
            entityConfig.isVersioned() ? entityConfig.getVersionComparatorAccess().get() : null);
    if (accessType == AccessType.READ_ONLY || !entityConfig.isMutable()) {
        return new ReadOnlyEntityDataAccess(accessType, accessDelegate, this);
    } else {//from w  ww  .j av a2s  .c  o m
        return new ReadWriteEntityDataAccess(accessType, accessDelegate, this);
    }
}

From source file:org.infinispan.hibernate.cache.v53.impl.DomainDataRegionImpl.java

License:LGPL

private void prepareForVersionedEntries(CacheMode cacheMode) {
    if (strategy != null) {
        assert strategy == Strategy.VERSIONED_ENTRIES;
        return;//ww w.ja  v  a2s  .c  om
    }

    prepareCommon(cacheMode);
    filter = VersionedEntry.EXCLUDE_EMPTY_VERSIONED_ENTRY;

    for (EntityDataCachingConfig entityConfig : config.getEntityCaching()) {
        if (entityConfig.isVersioned()) {
            for (NavigableRole role : entityConfig.getCachedTypes()) {
                comparatorsByType.put(role.getNavigableName(), entityConfig.getVersionComparatorAccess().get());
            }
        }
    }
    for (CollectionDataCachingConfig collectionConfig : config.getCollectionCaching()) {
        if (collectionConfig.isVersioned()) {
            comparatorsByType.put(collectionConfig.getNavigableRole().getNavigableName(),
                    collectionConfig.getOwnerVersionComparator());
        }
    }

    strategy = Strategy.VERSIONED_ENTRIES;
}