ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [4/5] ignite git commit: ignite-1794
Date Wed, 19 Apr 2017 14:36:08 GMT
http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateAccessStrategyAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateAccessStrategyAdapter.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateAccessStrategyAdapter.java
deleted file mode 100644
index eca44ee..0000000
--- a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateAccessStrategyAdapter.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.hibernate.core;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteCallable;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Common interface used to implement Hibernate L2 cache access strategies.
- * <p>
- * The expected sequences of steps related to various CRUD operations executed by Hibernate are:
- * <p>
- * Insert:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Execute database insert.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#insert}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#afterInsert}.</li>
- * </ul>
- * In case if some step fails and DB transaction is rolled back then
- * {@link HibernateAccessStrategyAdapter#afterInsert} is not called.
- * <p>
- * Update:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#lock}.</li>
- *     <li>Execute database update.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#update}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#afterUpdate}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * Delete:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#lock} for removing key.</li>
- *     <li>Execute database delete.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#remove}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#unlock}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * In case if custom SQL update query is executed Hibernate clears entire cache region,
- * for this case operations sequence is:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#lockRegion}.</li>
- *     <li>Execute database query.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#removeAll}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#unlockRegion}.</li>
- * </ul>
- */
-public abstract class HibernateAccessStrategyAdapter {
-    /** */
-    protected final HibernateCacheProxy cache;
-
-    /** Grid. */
-    protected final Ignite ignite;
-
-    /** */
-    protected final IgniteLogger log;
-
-    /**
-     * @param ignite Grid.
-     * @param cache Cache.
-     */
-    protected HibernateAccessStrategyAdapter(Ignite ignite, HibernateCacheProxy cache) {
-        this.cache = cache;
-        this.ignite = ignite;
-
-        log = ignite.log();
-    }
-
-    /**
-     * @param key Key.
-     * @return Cached value.
-     * @throws IgniteCheckedException If failed.
-     */
-    @Nullable protected Object get(Object key) throws IgniteCheckedException {
-        return cache.get(key);
-    }
-
-    /**
-     * @param key Key.
-     * @param val Value.
-     * @param minimalPutOverride MinimalPut flag
-     * @throws IgniteCheckedException If failed.
-     */
-    protected void putFromLoad(Object key, Object val, boolean minimalPutOverride) throws IgniteCheckedException {
-        putFromLoad(key, val);
-    }
-
-    /**
-     * Puts in cache value loaded from the database.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected void putFromLoad(Object key, Object val) throws IgniteCheckedException {
-        cache.put(key, val);
-    }
-
-    /**
-     * Called during database transaction execution before Hibernate attempts to update or remove given key.
-     *
-     * @param key Key.
-     */
-    protected abstract void lock(Object key);
-
-    /**
-     * Called after Hibernate failed to update or successfully removed given key.
-     *
-     * @param key Key.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract void unlock(Object key) throws IgniteCheckedException;
-
-    /**
-     * Called after Hibernate updated object in the database but before transaction completed.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code True} if operation updated cache.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract boolean update(Object key, Object val) throws IgniteCheckedException;
-
-    /**
-     * Called after Hibernate updated object in the database and transaction successfully completed.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code True} if operation updated cache.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract boolean afterUpdate(Object key, Object val) throws IgniteCheckedException;
-
-    /**
-     * Called after Hibernate inserted object in the database but before transaction completed.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code True} if operation updated cache.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract boolean insert(Object key, Object val) throws IgniteCheckedException;
-
-    /**
-     * Called after Hibernate inserted object in the database and transaction successfully completed.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code True} if operation updated cache.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract boolean afterInsert(Object key, Object val) throws IgniteCheckedException;
-
-    /**
-     * Called after Hibernate removed object from database but before transaction completed.
-     *
-     * @param key Key,
-     * @throws IgniteCheckedException If failed.
-     */
-    protected abstract void remove(Object key) throws IgniteCheckedException;
-
-    /**
-     * Called to remove object from cache without regard to transaction.
-     *
-     * @param key Key.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected void evict(Object key) throws IgniteCheckedException {
-        evict(ignite, cache, key);
-    }
-
-    /**
-     * Called to remove all data from cache without regard to transaction.
-     *
-     * @throws IgniteCheckedException If failed.
-     */
-    protected void evictAll() throws IgniteCheckedException {
-        evictAll(cache);
-    }
-
-    /**
-     * Called during database transaction execution to clear entire cache region after
-     * Hibernate executed database update, but before transaction completed.
-     *
-     * @throws IgniteCheckedException If failed.
-     */
-    protected final void removeAll() throws IgniteCheckedException {
-        evictAll();
-    }
-
-    /**
-     * Called during database transaction execution before Hibernate executed
-     * update operation which should invalidate entire cache region.
-     */
-    protected void lockRegion() {
-        // No-op.
-    }
-
-    /**
-     * Called after transaction clearing entire cache region completed.
-     */
-    protected void unlockRegion() {
-        // No-op.
-    }
-
-    /**
-     * Called to remove object from cache without regard to transaction.
-     *
-     * @param ignite Grid.
-     * @param cache Cache.
-     * @param key Key.
-     * @throws IgniteCheckedException If failed.
-     */
-    static void evict(Ignite ignite, HibernateCacheProxy cache, Object key) throws IgniteCheckedException {
-        try {
-            key = cache.keyTransformer().transform(key);
-
-            ignite.compute(ignite.cluster()).call(new ClearKeyCallable(key, cache.name()));
-        }
-        catch (IgniteException e) {
-            throw new IgniteCheckedException(e);
-        }
-    }
-
-    /**
-     * Called to remove all data from cache without regard to transaction.
-     *
-     * @param cache Cache.
-     * @throws IgniteCheckedException If failed.
-     */
-    static void evictAll(IgniteInternalCache<Object,Object> cache) throws IgniteCheckedException {
-        cache.clear();
-    }
-
-    /**
-     * Callable invalidates given key.
-     */
-    private static class ClearKeyCallable implements IgniteCallable<Void>, Externalizable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        private Object key;
-
-        /** */
-        private String cacheName;
-
-        /**
-         * Empty constructor required by {@link Externalizable}.
-         */
-        public ClearKeyCallable() {
-            // No-op.
-        }
-
-        /**
-         * @param key Key to clear.
-         * @param cacheName Cache name.
-         */
-        private ClearKeyCallable(Object key, String cacheName) {
-            this.key = key;
-            this.cacheName = cacheName;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() throws IgniteCheckedException {
-            IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
-            assert cache != null;
-
-            cache.clearLocally(key);
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws IOException {
-            out.writeObject(key);
-
-            U.writeString(out, cacheName);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            key = in.readObject();
-
-            cacheName = U.readString(in);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateCacheProxy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateCacheProxy.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateCacheProxy.java
deleted file mode 100644
index 984bb55..0000000
--- a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateCacheProxy.java
+++ /dev/null
@@ -1,811 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.hibernate.core;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
-import javax.cache.Cache;
-import javax.cache.expiry.ExpiryPolicy;
-import javax.cache.processor.EntryProcessor;
-import javax.cache.processor.EntryProcessorResult;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.cache.CacheEntry;
-import org.apache.ignite.cache.CacheMetrics;
-import org.apache.ignite.cache.CachePeekMode;
-import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cluster.ClusterGroup;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.internal.IgniteInternalFuture;
-import org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion;
-import org.apache.ignite.internal.processors.cache.CacheEntryPredicate;
-import org.apache.ignite.internal.processors.cache.GridCacheContext;
-import org.apache.ignite.internal.processors.cache.IgniteCacheExpiryPolicy;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
-import org.apache.ignite.lang.IgniteBiPredicate;
-import org.apache.ignite.mxbean.CacheMetricsMXBean;
-import org.apache.ignite.transactions.Transaction;
-import org.apache.ignite.transactions.TransactionConcurrency;
-import org.apache.ignite.transactions.TransactionIsolation;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Hibernate cache proxy used to substitute hibernate keys with ignite keys.
- */
-public class HibernateCacheProxy implements IgniteInternalCache<Object, Object> {
-    /** Delegate. */
-    private final IgniteInternalCache<Object, Object> delegate;
-
-    /** Transformer. */
-    private final HibernateKeyTransformer keyTransformer;
-
-    /**
-     * @param delegate Delegate.
-     * @param keyTransformer Key keyTransformer.
-     */
-    HibernateCacheProxy(
-        IgniteInternalCache<Object, Object> delegate,
-        HibernateKeyTransformer keyTransformer
-    ) {
-        assert delegate != null;
-        assert keyTransformer != null;
-
-        this.delegate = delegate;
-        this.keyTransformer = keyTransformer;
-    }
-
-    /**
-     * @return HibernateKeyTransformer
-     */
-    public HibernateKeyTransformer keyTransformer(){
-        return keyTransformer;
-    }
-
-    /** {@inheritDoc} */
-    @Override public String name() {
-        return delegate.name();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean skipStore() {
-        return delegate.skipStore();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalCache setSkipStore(boolean skipStore) {
-        return delegate.setSkipStore(skipStore);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isEmpty() {
-        return delegate.isEmpty();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsKey(Object key) {
-        return delegate.containsKey(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> containsKeyAsync(Object key) {
-        return delegate.containsKeyAsync(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean containsKeys(Collection keys) {
-        return delegate.containsKey(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> containsKeysAsync(Collection keys) {
-        return delegate.containsKeysAsync(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object localPeek(
-        Object key,
-        CachePeekMode[] peekModes,
-        @Nullable IgniteCacheExpiryPolicy plc
-    ) throws IgniteCheckedException {
-        return delegate.localPeek(keyTransformer.transform(key), peekModes, plc);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterable<Cache.Entry<Object, Object>> localEntries(
-        CachePeekMode[] peekModes
-    ) throws IgniteCheckedException {
-        return delegate.localEntries(peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object get(Object key) throws IgniteCheckedException {
-        return delegate.get(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public CacheEntry getEntry(Object key) throws IgniteCheckedException {
-        return delegate.getEntry(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture getAsync(Object key) {
-        return delegate.getAsync(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<CacheEntry<Object, Object>> getEntryAsync(Object key) {
-        return delegate.getEntryAsync(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map getAll(@Nullable Collection keys) throws IgniteCheckedException {
-        return delegate.getAll(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<CacheEntry<Object, Object>> getEntries(
-        @Nullable Collection keys) throws IgniteCheckedException {
-        return delegate.getEntries(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Map<Object, Object>> getAllAsync(@Nullable Collection keys) {
-        return delegate.getAllAsync(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Collection<CacheEntry<Object,Object>>> getEntriesAsync(
-        @Nullable Collection keys
-    ) {
-        return delegate.getEntriesAsync(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object getAndPut(Object key, Object val) throws IgniteCheckedException {
-        return delegate.getAndPut(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture getAndPutAsync(Object key, Object val) {
-        return delegate.getAndPutAsync(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean put(Object key, Object val) throws IgniteCheckedException {
-        return delegate.put(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> putAsync(Object key, Object val) {
-        return delegate.putAsync(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object getAndPutIfAbsent(Object key, Object val) throws IgniteCheckedException {
-        return delegate.getAndPutIfAbsent(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture getAndPutIfAbsentAsync(Object key, Object val) {
-        return delegate.getAndPutIfAbsentAsync(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean putIfAbsent(Object key, Object val) throws IgniteCheckedException {
-        return delegate.putIfAbsent(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> putIfAbsentAsync(Object key, Object val) {
-        return delegate.putIfAbsentAsync(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object getAndReplace(Object key, Object val) throws IgniteCheckedException {
-        return delegate.getAndReplace(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture getAndReplaceAsync(Object key, Object val) {
-        return delegate.getAndReplaceAsync(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean replace(Object key, Object val) throws IgniteCheckedException {
-        return delegate.replace(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object val) {
-        return delegate.replaceAsync(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean replace(Object key, Object oldVal, Object newVal) throws IgniteCheckedException {
-        return delegate.replace(keyTransformer.transform(key), oldVal, newVal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> replaceAsync(Object key, Object oldVal, Object newVal) {
-        return delegate.replaceAsync(keyTransformer.transform(key), oldVal, newVal);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void putAll(@Nullable Map m) throws IgniteCheckedException {
-        delegate.putAll(transform(m));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> putAllAsync(@Nullable Map m) {
-        return delegate.putAllAsync(transform(m));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set keySet() {
-        return delegate.keySet();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set keySetx() {
-        return delegate.keySetx();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set primaryKeySet() {
-        return delegate.primaryKeySet();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterable values() {
-        return delegate.values();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set<Cache.Entry<Object, Object>> entrySet() {
-        return delegate.entrySet();
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Set<Cache.Entry<Object,Object>> entrySet(int part) {
-        return delegate.entrySet(part);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Set<Cache.Entry<Object, Object>> entrySetx(CacheEntryPredicate... filter) {
-        return delegate.entrySetx(filter);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Transaction txStart(
-        TransactionConcurrency concurrency,
-        TransactionIsolation isolation
-    ) {
-        return delegate.txStart(concurrency, isolation);
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridNearTxLocal txStartEx(
-        TransactionConcurrency concurrency,
-        TransactionIsolation isolation
-    ) {
-        return delegate.txStartEx(concurrency, isolation);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Transaction txStart(
-        TransactionConcurrency concurrency,
-        TransactionIsolation isolation,
-        long timeout,
-        int txSize
-    ) {
-        return delegate.txStart(concurrency, isolation, timeout, txSize);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public GridNearTxLocal tx() {
-        return delegate.tx();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean evict(Object key) {
-        return delegate.evict(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void evictAll(@Nullable Collection keys) {
-        delegate.evictAll(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clearLocally(boolean srv, boolean near, boolean readers) {
-        delegate.clearLocally(srv, near, readers);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean clearLocally(Object key) {
-        return delegate.clearLocally(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clearLocallyAll(Set keys, boolean srv, boolean near, boolean readers) {
-        delegate.clearLocallyAll((Set<?>)transform(keys), srv, near, readers);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear(Object key) throws IgniteCheckedException {
-        delegate.clear(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clearAll(Set keys) throws IgniteCheckedException {
-        delegate.clearAll((Set<?>)transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void clear() throws IgniteCheckedException {
-        delegate.clear();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> clearAsync() {
-        return delegate.clearAsync();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> clearAsync(Object key) {
-        return delegate.clearAsync(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> clearAllAsync(Set keys) {
-        return delegate.clearAllAsync((Set<?>)transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object getAndRemove(Object key) throws IgniteCheckedException {
-        return delegate.getAndRemove(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture getAndRemoveAsync(Object key) {
-        return delegate.getAndRemoveAsync(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean remove(Object key) throws IgniteCheckedException {
-        return delegate.remove(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> removeAsync(Object key) {
-        return delegate.removeAsync(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean remove(Object key, Object val) throws IgniteCheckedException {
-        return delegate.remove(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> removeAsync(Object key, Object val) {
-        return delegate.removeAsync(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void removeAll(@Nullable Collection keys) throws IgniteCheckedException {
-        delegate.removeAll(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> removeAllAsync(@Nullable Collection keys) {
-        return delegate.removeAllAsync(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void removeAll() throws IgniteCheckedException {
-        delegate.removeAll();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> removeAllAsync() {
-        return delegate.removeAllAsync();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean lock(Object key, long timeout) throws IgniteCheckedException {
-        return delegate.lock(keyTransformer.transform(key), timeout);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> lockAsync(Object key, long timeout) {
-        return delegate.lockAsync(keyTransformer.transform(key), timeout);
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean lockAll(@Nullable Collection keys, long timeout) throws IgniteCheckedException {
-        return delegate.lockAll(transform(keys), timeout);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Boolean> lockAllAsync(@Nullable Collection keys, long timeout) {
-        return delegate.lockAllAsync(transform(keys), timeout);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void unlock(Object key) throws IgniteCheckedException {
-        delegate.unlock(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public void unlockAll(@Nullable Collection keys) throws IgniteCheckedException {
-        delegate.unlockAll(transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isLocked(Object key) {
-        return delegate.isLocked(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isLockedByThread(Object key) {
-        return delegate.isLockedByThread(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size() {
-        return delegate.size();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long sizeLong() {
-        return delegate.sizeLong();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int localSize(CachePeekMode[] peekModes) throws IgniteCheckedException {
-        return delegate.localSize(peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long localSizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
-        return delegate.localSizeLong(peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long localSizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
-        return delegate.localSizeLong(partition, peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int size(CachePeekMode[] peekModes) throws IgniteCheckedException {
-        return delegate.size(peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long sizeLong(CachePeekMode[] peekModes) throws IgniteCheckedException {
-        return delegate.sizeLong(peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public long sizeLong(int partition, CachePeekMode[] peekModes) throws IgniteCheckedException {
-        return delegate.sizeLong(partition, peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Integer> sizeAsync(CachePeekMode[] peekModes) {
-        return delegate.sizeAsync(peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Long> sizeLongAsync(CachePeekMode[] peekModes) {
-        return delegate.sizeLongAsync(peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Long> sizeLongAsync(int partition, CachePeekMode[] peekModes) {
-        return delegate.sizeLongAsync(partition, peekModes);
-    }
-
-    /** {@inheritDoc} */
-    @Override public int nearSize() {
-        return delegate.nearSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public int primarySize() {
-        return delegate.primarySize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long primarySizeLong() {
-        return delegate.primarySizeLong();
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheConfiguration configuration() {
-        return delegate.configuration();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Affinity affinity() {
-        return delegate.affinity();
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetrics clusterMetrics() {
-        return delegate.clusterMetrics();
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetrics clusterMetrics(ClusterGroup grp) {
-        return delegate.clusterMetrics(grp);
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetrics localMetrics() {
-        return delegate.localMetrics();
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetricsMXBean clusterMxBean() {
-        return delegate.clusterMxBean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public CacheMetricsMXBean localMxBean() {
-        return delegate.localMxBean();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long offHeapEntriesCount() {
-        return delegate.offHeapEntriesCount();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long offHeapAllocatedSize() {
-        return delegate.offHeapAllocatedSize();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> rebalance() {
-        return delegate.rebalance();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalCache forSubjectId(UUID subjId) {
-        return delegate.forSubjectId(subjId);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object getForcePrimary(Object key) throws IgniteCheckedException {
-        return delegate.getForcePrimary(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture getForcePrimaryAsync(Object key) {
-        return delegate.getForcePrimaryAsync(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map getAllOutTx(Set keys) throws IgniteCheckedException {
-        return delegate.getAllOutTx((Set<?>)transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Map<Object, Object>> getAllOutTxAsync(Set keys) {
-        return delegate.getAllOutTxAsync((Set<?>)transform(keys));
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isIgfsDataCache() {
-        return delegate.isIgfsDataCache();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long igfsDataSpaceUsed() {
-        return delegate.igfsDataSpaceUsed();
-    }
-
-    /** {@inheritDoc} */
-    @Override public long igfsDataSpaceMax() {
-        return delegate.igfsDataSpaceMax();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isMongoDataCache() {
-        return delegate.isMongoDataCache();
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean isMongoMetaCache() {
-        return delegate.isMongoMetaCache();
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public ExpiryPolicy expiry() {
-        return delegate.expiry();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalCache withExpiryPolicy(ExpiryPolicy plc) {
-        return delegate.withExpiryPolicy(plc);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalCache withNoRetries() {
-        return delegate.withNoRetries();
-    }
-
-    /** {@inheritDoc} */
-    @Override public GridCacheContext context() {
-        return delegate.context();
-    }
-
-    /** {@inheritDoc} */
-    @Override public void localLoadCache(
-        @Nullable IgniteBiPredicate p,
-        @Nullable Object... args
-    ) throws IgniteCheckedException {
-        delegate.localLoadCache(p, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> localLoadCacheAsync(
-        @Nullable IgniteBiPredicate p,
-        @Nullable Object... args
-    ) {
-        return delegate.localLoadCacheAsync(p, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Object getTopologySafe(Object key) throws IgniteCheckedException {
-        return delegate.getTopologySafe(keyTransformer.transform(key));
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public Object tryGetAndPut(Object key, Object val) throws IgniteCheckedException {
-        return delegate.tryGetAndPut(keyTransformer.transform(key), val);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Collection<Integer> lostPartitions() {
-        return delegate.lostPartitions();
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public EntryProcessorResult invoke(
-        @Nullable AffinityTopologyVersion topVer,
-        Object key,
-        EntryProcessor entryProcessor,
-        Object... args
-    ) throws IgniteCheckedException {
-        return delegate.invoke(topVer, key, entryProcessor, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Map> invokeAllAsync(Map map, Object... args) {
-        return delegate.invokeAllAsync(map, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map invokeAll(Map map, Object... args) throws IgniteCheckedException {
-        return delegate.invokeAll(map, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<Map> invokeAllAsync(Set keys, EntryProcessor entryProcessor, Object... args) {
-        return delegate.invokeAllAsync((Set<?>)transform(keys), entryProcessor, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Map invokeAll(Set keys, EntryProcessor entryProcessor, Object... args) throws IgniteCheckedException {
-        return delegate.invokeAll((Set<?>)transform(keys), entryProcessor, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<EntryProcessorResult> invokeAsync(
-        Object key,
-        EntryProcessor entryProcessor,
-        Object... args
-    ) {
-        return delegate.invokeAsync(keyTransformer.transform(key), entryProcessor, args);
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public EntryProcessorResult invoke(
-        Object key,
-        EntryProcessor entryProcessor,
-        Object... args
-    ) throws IgniteCheckedException {
-        return delegate.invoke(keyTransformer.transform(key), entryProcessor, args);
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterator<Cache.Entry<Object,Object>> scanIterator(
-        boolean keepBinary,
-        @Nullable IgniteBiPredicate p
-    ) throws IgniteCheckedException {
-        return delegate.scanIterator(keepBinary, p);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> removeAllConflictAsync(Map drMap) throws IgniteCheckedException {
-        return delegate.removeAllConflictAsync(drMap);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void removeAllConflict(Map drMap) throws IgniteCheckedException {
-        delegate.removeAllConflictAsync(drMap);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalFuture<?> putAllConflictAsync(Map drMap) throws IgniteCheckedException {
-        return delegate.putAllConflictAsync(drMap);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void putAllConflict(Map drMap) throws IgniteCheckedException {
-        delegate.putAllConflict(drMap);
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalCache keepBinary() {
-        return delegate.keepBinary();
-    }
-
-    /** {@inheritDoc} */
-    @Override public IgniteInternalCache cache() {
-        return delegate.cache();
-    }
-
-    /** {@inheritDoc} */
-    @Override public Iterator iterator() {
-        return delegate.iterator();
-    }
-
-    /**
-     * @param keys Keys.
-     */
-    private Collection<Object> transform(Collection<Object> keys) {
-        Collection<Object> res = new LinkedList<>();
-
-        for (Object o : keys)
-            res.add(keyTransformer.transform(o));
-
-        return res;
-    }
-
-    /**
-     * @param map Map.
-     */
-    private Map<Object, Object> transform(Map<Object, Object> map) {
-        Map<Object, Object> res = new HashMap<>();
-
-        Set<Map.Entry<Object, Object>> ents = map.entrySet();
-
-        for (Map.Entry<Object, Object> e : ents)
-            res.put(keyTransformer.transform(e.getKey()), e.getValue());
-
-        return res;
-    }
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateKeyTransformer.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateKeyTransformer.java b/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateKeyTransformer.java
deleted file mode 100644
index 5526d0e..0000000
--- a/modules/hibernate-core/src/main/java/org/apache/ignite/cache/hibernate/core/HibernateKeyTransformer.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.hibernate.core;
-
-/**
- * An interface for transforming hibernate keys to Ignite keys.
- */
-public interface HibernateKeyTransformer {
-    /**
-     * @param key Hibernate key.
-     */
-    public Object transform(Object key);
-}

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
index 7186cfb..8bf4e9b 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
@@ -27,12 +27,12 @@ import org.jetbrains.annotations.Nullable;
  */
 public abstract class HibernateAbstractRegionAccessStrategy implements RegionAccessStrategy {
     /** */
-    protected final HibernateAccessStrategyAdapter stgy;
+    final HibernateAccessStrategyAdapter stgy;
 
     /**
      * @param stgy Access strategy implementation.
      */
-    protected HibernateAbstractRegionAccessStrategy(HibernateAccessStrategyAdapter stgy) {
+    HibernateAbstractRegionAccessStrategy(HibernateAccessStrategyAdapter stgy) {
         this.stgy = stgy;
     }
 
@@ -58,22 +58,26 @@ public abstract class HibernateAbstractRegionAccessStrategy implements RegionAcc
 
     /** {@inheritDoc} */
     @Nullable @Override public SoftLock lockItem(Object key, Object ver) throws CacheException {
-        return stgy.lock(key);
+        stgy.lock(key);
+
+        return null;
     }
 
     /** {@inheritDoc} */
     @Nullable @Override public SoftLock lockRegion() throws CacheException {
-        return stgy.lockRegion();
+        stgy.lockRegion();
+
+        return null;
     }
 
     /** {@inheritDoc} */
     @Override public void unlockRegion(SoftLock lock) throws CacheException {
-        stgy.unlockRegion(lock);
+        stgy.unlockRegion();
     }
 
     /** {@inheritDoc} */
     @Override public void unlockItem(Object key, SoftLock lock) throws CacheException {
-        stgy.unlock(key, lock);
+        stgy.unlock(key);
     }
 
     /** {@inheritDoc} */

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
deleted file mode 100644
index 1036856..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAccessStrategyAdapter.java
+++ /dev/null
@@ -1,380 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.hibernate;
-
-import java.io.Externalizable;
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.IgniteLogger;
-import org.apache.ignite.cache.hibernate.core.HibernateCacheProxy;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
-import org.apache.ignite.internal.util.typedef.internal.U;
-import org.apache.ignite.lang.IgniteCallable;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
-import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
-import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
-import org.hibernate.cache.spi.access.RegionAccessStrategy;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Common interface used to implement Hibernate L2 cache access strategies ({@link RegionAccessStrategy},
- * {@link EntityRegionAccessStrategy} and {@link CollectionRegionAccessStrategy}).
- * <p>
- * The expected sequences of steps related to various CRUD operations executed by Hibernate are:
- * <p>
- * Insert:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Execute database insert.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#insert}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#afterInsert}.</li>
- * </ul>
- * In case if some step fails and DB transaction is rolled back then
- * {@link HibernateAccessStrategyAdapter#afterInsert} is not called.
- * <p>
- * Update:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#lock}.</li>
- *     <li>Execute database update.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#update}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#afterUpdate}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * Delete:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#lock} for removing key.</li>
- *     <li>Execute database delete.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#remove}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#unlock}.</li>
- * </ul>
- * In case if {@link HibernateAccessStrategyAdapter#lock} was called, but some other step fails and DB
- * transaction is rolled back then {@link HibernateAccessStrategyAdapter#unlock} is called for all locked keys.
- * <p>
- * In case if custom SQL update query is executed Hibernate clears entire cache region,
- * for this case operations sequence is:
- * <ul>
- *     <li>Start DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#lockRegion}.</li>
- *     <li>Execute database query.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#removeAll}.</li>
- *     <li>Commit DB transaction.</li>
- *     <li>Call {@link HibernateAccessStrategyAdapter#unlockRegion}.</li>
- * </ul>
- */
-public abstract class HibernateAccessStrategyAdapter {
-    /** */
-    protected final HibernateCacheProxy cache;
-
-    /** Grid. */
-    protected final Ignite ignite;
-
-    /** */
-    protected final IgniteLogger log;
-
-    /**
-     * @param ignite Grid.
-     * @param cache Cache.
-     */
-    protected HibernateAccessStrategyAdapter(Ignite ignite, HibernateCacheProxy cache) {
-        this.cache = cache;
-        this.ignite = ignite;
-
-        log = ignite.log();
-    }
-
-    /**
-     * Gets value from cache. Used by {@link RegionAccessStrategy#get}.
-     *
-     * @param key Key.
-     * @return Cached value.
-     * @throws CacheException If failed.
-     */
-    @Nullable protected Object get(Object key) throws CacheException {
-        try {
-            return cache.get(key);
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-    }
-
-    /**
-     * Puts in cache value loaded from the database. Used by {@link RegionAccessStrategy#putFromLoad}.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @param minimalPutOverride MinimalPut flag
-     * @throws CacheException If failed.
-     */
-    protected void putFromLoad(Object key, Object val, boolean minimalPutOverride) throws CacheException {
-        putFromLoad(key, val);
-    }
-
-    /**
-     * Puts in cache value loaded from the database. Used by {@link RegionAccessStrategy#putFromLoad}.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @throws CacheException If failed.
-     */
-    protected void putFromLoad(Object key, Object val) throws CacheException {
-        try {
-            cache.put(key, val);
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-    }
-
-    /**
-     * Called during database transaction execution before Hibernate attempts to update or remove given key.
-     * Used by {@link RegionAccessStrategy#lockItem}.
-     *
-     * @param key Key.
-     * @return Lock representation or {@code null}.
-     * @throws CacheException If failed.
-     */
-    @Nullable protected abstract SoftLock lock(Object key) throws CacheException;
-
-    /**
-     * Called after Hibernate failed to update or successfully removed given key.
-     * Used by {@link RegionAccessStrategy#unlockItem}.
-     *
-     * @param key Key.
-     * @param lock The lock previously obtained from {@link #lock}
-     * @throws CacheException If failed.
-     */
-    protected abstract void unlock(Object key, SoftLock lock) throws CacheException;
-
-    /**
-     * Called after Hibernate updated object in the database but before transaction completed.
-     * Used by {@link EntityRegionAccessStrategy#update} and {@link NaturalIdRegionAccessStrategy#update}.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code True} if operation updated cache.
-     * @throws CacheException If failed.
-     */
-    protected abstract boolean update(Object key, Object val) throws CacheException;
-
-    /**
-     * Called after Hibernate updated object in the database and transaction successfully completed.
-     * Used by {@link EntityRegionAccessStrategy#afterUpdate} and {@link NaturalIdRegionAccessStrategy#afterUpdate}.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @param lock The lock previously obtained from {@link #lock}
-     * @return {@code True} if operation updated cache.
-     * @throws CacheException If failed.
-     */
-    protected abstract boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException;
-
-    /**
-     * Called after Hibernate inserted object in the database but before transaction completed.
-     * Used by {@link EntityRegionAccessStrategy#insert} and {@link NaturalIdRegionAccessStrategy#insert}.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code True} if operation updated cache.
-     * @throws CacheException If failed.
-     */
-    protected abstract boolean insert(Object key, Object val) throws CacheException;
-
-    /**
-     * Called after Hibernate inserted object in the database and transaction successfully completed.
-     * Used by {@link EntityRegionAccessStrategy#afterInsert} and {@link NaturalIdRegionAccessStrategy#afterInsert}.
-     *
-     * @param key Key.
-     * @param val Value.
-     * @return {@code True} if operation updated cache.
-     * @throws CacheException If failed.
-     */
-    protected abstract boolean afterInsert(Object key, Object val) throws CacheException;
-
-    /**
-     * Called after Hibernate removed object from database but before transaction completed.
-     * Used by {@link RegionAccessStrategy#remove}.
-     *
-     * @param key Key,
-     * @throws CacheException If failed.
-     */
-    protected abstract void remove(Object key) throws CacheException;
-
-    /**
-     * Called to remove object from cache without regard to transaction.
-     * Used by {@link RegionAccessStrategy#evict}.
-     *
-     * @param key Key.
-     * @throws CacheException If failed.
-     */
-    protected void evict(Object key) throws CacheException {
-        evict(ignite, cache, key);
-    }
-
-    /**
-     * Called to remove all data from cache without regard to transaction.
-     * Used by {@link RegionAccessStrategy#evictAll}.
-     *
-     * @throws CacheException If failed.
-     */
-    protected void evictAll() throws CacheException {
-        evictAll(cache);
-    }
-
-    /**
-     * Called during database transaction execution before Hibernate executed
-     * update operation which should invalidate entire cache region.
-     * Used by {@link RegionAccessStrategy#lockRegion}.
-     *
-     * @throws CacheException If failed.
-     * @return Lock representation or {@code null}.
-     */
-    @Nullable protected SoftLock lockRegion() throws CacheException {
-        return null;
-    }
-
-    /**
-     * Called after transaction clearing entire cache region completed.
-     * Used by {@link RegionAccessStrategy#unlockRegion}.
-     *
-     * @param lock The lock previously obtained from {@link #lockRegion}
-     * @throws CacheException If failed.
-     */
-    protected void unlockRegion(SoftLock lock) throws CacheException {
-        // No-op.
-    }
-
-    /**
-     * Called during database transaction execution to clear entire cache region after
-     * Hibernate executed database update, but before transaction completed.
-     * Used by {@link RegionAccessStrategy#removeAll}.
-     *
-     * @throws CacheException If failed.
-     */
-    protected final void removeAll() throws CacheException {
-        evictAll();
-    }
-
-    /**
-     * Called to remove object from cache without regard to transaction.
-     *
-     * @param ignite Grid.
-     * @param cache Cache.
-     * @param key Key.
-     * @throws CacheException If failed.
-     */
-    static void evict(Ignite ignite, HibernateCacheProxy cache, Object key) throws CacheException {
-        try {
-            key = cache.keyTransformer().transform(key);
-
-            ignite.compute(ignite.cluster()).call(new ClearKeyCallable(key, cache.name()));
-        }
-        catch (IgniteException e) {
-            throw new CacheException(e);
-        }
-    }
-
-    /**
-     * Called to remove all data from cache without regard to transaction.
-     *
-     * @param cache Cache.
-     * @throws CacheException If failed.
-     */
-    static void evictAll(IgniteInternalCache<Object,Object> cache) throws CacheException {
-        try {
-            cache.clear();
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-    }
-
-    /**
-     * Callable invalidates given key.
-     */
-    private static class ClearKeyCallable implements IgniteCallable<Void>, Externalizable {
-        /** */
-        private static final long serialVersionUID = 0L;
-
-        /** */
-        @IgniteInstanceResource
-        private Ignite ignite;
-
-        /** */
-        private Object key;
-
-        /** */
-        private String cacheName;
-
-        /**
-         * Empty constructor required by {@link Externalizable}.
-         */
-        public ClearKeyCallable() {
-            // No-op.
-        }
-
-        /**
-         * @param key Key to clear.
-         * @param cacheName Cache name.
-         */
-        private ClearKeyCallable(Object key, String cacheName) {
-            this.key = key;
-            this.cacheName = cacheName;
-        }
-
-        /** {@inheritDoc} */
-        @Override public Void call() throws IgniteCheckedException {
-            IgniteInternalCache<Object, Object> cache = ((IgniteKernal)ignite).getCache(cacheName);
-
-            assert cache != null;
-
-            cache.clearLocally(key);
-
-            return null;
-        }
-
-        /** {@inheritDoc} */
-        @Override public void writeExternal(ObjectOutput out) throws IOException {
-            out.writeObject(key);
-
-            U.writeString(out, cacheName);
-        }
-
-        /** {@inheritDoc} */
-        @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            key = in.readObject();
-
-            cacheName = U.readString(in);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
index eb35a2c..dae476c 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
@@ -70,7 +70,7 @@ public class HibernateCollectionRegion extends HibernateTransactionalDataRegion
      * @param cache Region cache.
      * @param dataDesc Region data description.
      */
-    public HibernateCollectionRegion(HibernateRegionFactory factory, String name,
+    HibernateCollectionRegion(HibernateRegionFactory factory, String name,
         Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
         super(factory, name, ignite, cache, dataDesc);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
index ad5b191..db921dc 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
@@ -60,7 +60,7 @@ public class HibernateEntityRegion extends HibernateTransactionalDataRegion impl
      * @param cache Region cache,
      * @param dataDesc Region data description.
      */
-    public HibernateEntityRegion(HibernateRegionFactory factory, String name, Ignite ignite,
+    HibernateEntityRegion(HibernateRegionFactory factory, String name, Ignite ignite,
         HibernateCacheProxy cache, CacheDataDescription dataDesc) {
         super(factory, name, ignite, cache, dataDesc);
     }
@@ -106,7 +106,7 @@ public class HibernateEntityRegion extends HibernateTransactionalDataRegion impl
         /** {@inheritDoc} */
         @Override public boolean afterUpdate(Object key, Object val, Object currVer, Object previousVer, SoftLock lock)
             throws CacheException {
-            return stgy.afterUpdate(key, val, lock);
+            return stgy.afterUpdate(key, val);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
index 2f1a11d..578d88b 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
@@ -36,7 +36,7 @@ public class HibernateGeneralDataRegion extends HibernateRegion implements Gener
      * @param ignite Grid.
      * @param cache Region cache.
      */
-    public HibernateGeneralDataRegion(HibernateRegionFactory factory, String name,
+    HibernateGeneralDataRegion(HibernateRegionFactory factory, String name,
         Ignite ignite, HibernateCacheProxy cache) {
         super(factory, name, ignite, cache);
     }
@@ -66,6 +66,11 @@ public class HibernateGeneralDataRegion extends HibernateRegion implements Gener
 
     /** {@inheritDoc} */
     @Override public void evictAll() throws CacheException {
-        HibernateAccessStrategyAdapter.evictAll(cache);
+        try {
+            HibernateAccessStrategyAdapter.evictAll(cache);
+        }
+        catch (IgniteCheckedException e) {
+            throw HibernateRegionFactory.EXCEPTION_CONVERTER.convert(e);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
index 7de440e..64de395 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
@@ -17,12 +17,13 @@
 
 package org.apache.ignite.cache.hibernate;
 
+import java.io.Serializable;
 import org.apache.ignite.internal.util.typedef.internal.S;
 
 /**
  * Hibernate cache key wrapper.
  */
-public class HibernateKeyWrapper {
+public class HibernateKeyWrapper implements Serializable {
     /** Key. */
     private final Object key;
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
index 862a422..ae1099d 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
@@ -50,8 +50,11 @@ public class HibernateNaturalIdRegion extends HibernateTransactionalDataRegion i
      * @param cache Region cache,
      * @param dataDesc Region data description.
      */
-    public HibernateNaturalIdRegion(HibernateRegionFactory factory, String name,
-        Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+    HibernateNaturalIdRegion(HibernateRegionFactory factory,
+        String name,
+        Ignite ignite,
+        HibernateCacheProxy cache,
+        CacheDataDescription dataDesc) {
         super(factory, name, ignite, cache, dataDesc);
     }
 
@@ -94,7 +97,7 @@ public class HibernateNaturalIdRegion extends HibernateTransactionalDataRegion i
 
         /** {@inheritDoc} */
         @Override public boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
-            return stgy.afterUpdate(key, val, lock);
+            return stgy.afterUpdate(key, val);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
deleted file mode 100644
index a36d7e7..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNonStrictAccessStrategy.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.hibernate;
-
-import java.util.Map;
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.util.GridLeanMap;
-import org.apache.ignite.internal.util.GridLeanSet;
-import org.apache.ignite.internal.util.typedef.F;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#NONSTRICT_READ_WRITE} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * &lt;hibernate-configuration&gt;
- *     &lt;!-- Enable L2 cache. --&gt;
- *     &lt;property name="cache.use_second_level_cache"&gt;true&lt;/property&gt;
- *
- *     &lt;!-- Use Ignite as L2 cache provider. --&gt;
- *     &lt;property name="cache.region.factory_class"&gt;org.apache.ignite.cache.hibernate.HibernateRegionFactory&lt;/property&gt;
- *
- *     &lt;!-- Specify entity. --&gt;
- *     &lt;mapping class="com.example.Entity"/&gt;
- *
- *     &lt;!-- Enable L2 cache with nonstrict-read-write access strategy for entity. --&gt;
- *     &lt;class-cache class="com.example.Entity" usage="nonstrict-read-write"/&gt;
- * &lt;/hibernate-configuration&gt;
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * &#064;javax.persistence.Entity
- * &#064;javax.persistence.Cacheable
- * &#064;org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateNonStrictAccessStrategy extends HibernateAccessStrategyAdapter {
-    /** */
-    private final ThreadLocal<WriteContext> writeCtx;
-
-    /**
-     * @param ignite Grid.
-     * @param cache Cache.
-     * @param writeCtx Thread local instance used to track updates done during one Hibernate transaction.
-     */
-    protected HibernateNonStrictAccessStrategy(Ignite ignite, HibernateCacheProxy cache, ThreadLocal writeCtx) {
-        super(ignite, cache);
-
-        this.writeCtx = (ThreadLocal<WriteContext>)writeCtx;
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override protected SoftLock lock(Object key) throws CacheException {
-        WriteContext ctx = writeCtx.get();
-
-        if (ctx == null)
-            writeCtx.set(ctx = new WriteContext());
-
-        ctx.locked(key);
-
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
-        try {
-            WriteContext ctx = writeCtx.get();
-
-            if (ctx != null && ctx.unlocked(key)) {
-                writeCtx.remove();
-
-                ctx.updateCache(cache);
-            }
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean update(Object key, Object val) throws CacheException {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
-        WriteContext ctx = writeCtx.get();
-
-        if (ctx != null) {
-            ctx.updated(key, val);
-
-            unlock(key, lock);
-
-            return true;
-        }
-
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean insert(Object key, Object val) throws CacheException {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
-        try {
-            cache.put(key, val);
-
-            return true;
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void remove(Object key) throws CacheException {
-        WriteContext ctx = writeCtx.get();
-
-        if (ctx != null)
-            ctx.removed(key);
-    }
-
-    /**
-     * Information about updates done during single database transaction.
-     */
-    @SuppressWarnings("TypeMayBeWeakened")
-    private static class WriteContext {
-        /** */
-        private Map<Object, Object> updates;
-
-        /** */
-        private Set<Object> rmvs;
-
-        /** */
-        private Set<Object> locked = new GridLeanSet<>();
-
-        /**
-         * Marks key as locked.
-         *
-         * @param key Key.
-         */
-        void locked(Object key) {
-            locked.add(key);
-        }
-
-        /**
-         * Marks key as unlocked.
-         *
-         * @param key Key.
-         * @return {@code True} if last locked key was unlocked.
-         */
-        boolean unlocked(Object key) {
-            locked.remove(key);
-
-            return locked.isEmpty();
-        }
-
-        /**
-         * Marks key as updated.
-         *
-         * @param key Key.
-         * @param val Value.
-         */
-        void updated(Object key, Object val) {
-            if (updates == null)
-                updates = new GridLeanMap<>();
-
-            updates.put(key, val);
-        }
-
-        /**
-         * Marks key as removed.
-         *
-         * @param key Key.
-         */
-        void removed(Object key) {
-            if (rmvs == null)
-                rmvs = new GridLeanSet<>();
-
-            rmvs.add(key);
-        }
-
-        /**
-         * Updates cache.
-         *
-         * @param cache Cache.
-         * @throws IgniteCheckedException If failed.
-         */
-        void updateCache(HibernateCacheProxy cache) throws IgniteCheckedException {
-            if (!F.isEmpty(rmvs))
-                cache.removeAll(rmvs);
-
-            if (!F.isEmpty(updates))
-                cache.putAll(updates);
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
index 0b9a43d..fccbb5e 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
@@ -56,14 +56,14 @@ import org.hibernate.cache.spi.QueryResultsRegion;
  * values. For this reason, the query cache should always be used in conjunction with
  * the second-level cache for those entities expected to be cached as part of a query result cache
  */
-public class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements QueryResultsRegion {
+class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements QueryResultsRegion {
     /**
      * @param factory Region factory.
      * @param name Region name.
      * @param ignite Grid.
      * @param cache Region cache.
      */
-    public HibernateQueryResultsRegion(HibernateRegionFactory factory, String name,
+    HibernateQueryResultsRegion(HibernateRegionFactory factory, String name,
         Ignite ignite, HibernateCacheProxy cache) {
         super(factory, name, ignite, cache);
     }

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
deleted file mode 100644
index cdef80e..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadOnlyAccessStrategy.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.hibernate;
-
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * Implementation of {@link AccessType#READ_ONLY} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * &lt;hibernate-configuration&gt;
- *     &lt;!-- Enable L2 cache. --&gt;
- *     &lt;property name="cache.use_second_level_cache"&gt;true&lt;/property&gt;
- *
- *     &lt;!-- Use Ignite as L2 cache provider. --&gt;
- *     &lt;property name="cache.region.factory_class"&gt;org.apache.ignite.cache.hibernate.HibernateRegionFactory&lt;/property&gt;
- *
- *     &lt;!-- Specify entity. --&gt;
- *     &lt;mapping class="com.example.Entity"/&gt;
- *
- *     &lt;!-- Enable L2 cache with read-only access strategy for entity. --&gt;
- *     &lt;class-cache class="com.example.Entity" usage="read-only"/&gt;
- * &lt;/hibernate-configuration&gt;
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * &#064;javax.persistence.Entity
- * &#064;javax.persistence.Cacheable
- * &#064;org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_ONLY)
- * public class Entity { ... }
- * </pre>
-
- *
- */
-public class HibernateReadOnlyAccessStrategy extends HibernateAccessStrategyAdapter {
-    /**
-     * @param ignite Grid.
-     * @param cache Cache.
-     */
-    public HibernateReadOnlyAccessStrategy(Ignite ignite, HibernateCacheProxy cache) {
-        super(ignite, cache);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean insert(Object key, Object val) throws CacheException {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
-        try {
-            cache.put(key, val);
-
-            return true;
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override protected SoftLock lock(Object key) throws CacheException {
-        return null;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void remove(Object key) throws CacheException {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean update(Object key, Object val) throws CacheException {
-        throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
-        throw new UnsupportedOperationException("Updates are not supported for read-only access strategy.");
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/979d8722/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
deleted file mode 100644
index ae9bd71..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateReadWriteAccessStrategy.java
+++ /dev/null
@@ -1,328 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.cache.hibernate;
-
-import java.util.Set;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal;
-import org.apache.ignite.internal.util.GridLeanSet;
-import org.hibernate.cache.CacheException;
-import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cache.spi.access.SoftLock;
-
-import static org.apache.ignite.transactions.TransactionConcurrency.PESSIMISTIC;
-import static org.apache.ignite.transactions.TransactionIsolation.REPEATABLE_READ;
-
-/**
- * Implementation of {@link AccessType#READ_WRITE} cache access strategy.
- * <p>
- * Configuration of L2 cache and per-entity cache access strategy can be set in the
- * Hibernate configuration file:
- * <pre name="code" class="xml">
- * &lt;hibernate-configuration&gt;
- *     &lt;!-- Enable L2 cache. --&gt;
- *     &lt;property name="cache.use_second_level_cache"&gt;true&lt;/property&gt;
- *
- *     &lt;!-- Use Ignite as L2 cache provider. --&gt;
- *     &lt;property name="cache.region.factory_class"&gt;org.apache.ignite.cache.hibernate.HibernateRegionFactory&lt;/property&gt;
- *
- *     &lt;!-- Specify entity. --&gt;
- *     &lt;mapping class="com.example.Entity"/&gt;
- *
- *     &lt;!-- Enable L2 cache with read-write access strategy for entity. --&gt;
- *     &lt;class-cache class="com.example.Entity" usage="read-write"/&gt;
- * &lt;/hibernate-configuration&gt;
- * </pre>
- * Also cache access strategy can be set using annotations:
- * <pre name="code" class="java">
- * &#064;javax.persistence.Entity
- * &#064;javax.persistence.Cacheable
- * &#064;org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
- * public class Entity { ... }
- * </pre>
- */
-public class HibernateReadWriteAccessStrategy extends HibernateAccessStrategyAdapter {
-    /** */
-    private final ThreadLocal<TxContext> txCtx;
-
-    /**
-     * @param ignite Grid.
-     * @param cache Cache.
-     * @param txCtx Thread local instance used to track updates done during one Hibernate transaction.
-     */
-    protected HibernateReadWriteAccessStrategy(Ignite ignite, HibernateCacheProxy cache, ThreadLocal txCtx) {
-        super(ignite, cache);
-
-        this.txCtx = (ThreadLocal<TxContext>)txCtx;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected Object get(Object key) throws CacheException {
-        boolean success = false;
-
-        try {
-            Object o = cache.get(key);
-
-            success = true;
-
-            return o;
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-        finally {
-            if (!success)
-                rollbackCurrentTx();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void putFromLoad(Object key, Object val) throws CacheException {
-        boolean success = false;
-
-        try {
-            cache.put(key, val);
-
-            success = true;
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-        finally {
-            if (!success)
-                rollbackCurrentTx();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected SoftLock lock(Object key) throws CacheException {
-        boolean success = false;
-
-        try {
-            TxContext ctx = txCtx.get();
-
-            if (ctx == null)
-                txCtx.set(ctx = new TxContext());
-
-            lockKey(key);
-
-            ctx.locked(key);
-
-            success = true;
-
-            return null;
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-        finally {
-            if (!success)
-                rollbackCurrentTx();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void unlock(Object key, SoftLock lock) throws CacheException {
-        boolean success = false;
-
-        try {
-            TxContext ctx = txCtx.get();
-
-            if (ctx != null)
-                unlock(ctx, key);
-
-            success = true;
-        }
-        catch (Exception e) {
-            throw new CacheException(e);
-        }
-        finally {
-            if (!success)
-                rollbackCurrentTx();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean update(Object key, Object val) throws CacheException {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
-        boolean success = false;
-        boolean res = false;
-
-        try {
-            TxContext ctx = txCtx.get();
-
-            if (ctx != null) {
-                cache.put(key, val);
-
-                unlock(ctx, key);
-
-                res = true;
-            }
-
-            success = true;
-
-            return res;
-        }
-        catch (Exception e) {
-            throw new CacheException(e);
-        }
-        finally {
-            if (!success)
-                rollbackCurrentTx();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean insert(Object key, Object val) throws CacheException {
-        return false;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected boolean afterInsert(Object key, Object val) throws CacheException {
-        boolean success = false;
-
-        try {
-            cache.put(key, val);
-
-            success = true;
-
-            return true;
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-        finally {
-            if (!success)
-                rollbackCurrentTx();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void remove(Object key) throws CacheException {
-        boolean success = false;
-
-        try {
-            TxContext ctx = txCtx.get();
-
-            if (ctx != null)
-                cache.remove(key);
-
-            success = true;
-        }
-        catch (IgniteCheckedException e) {
-            throw new CacheException(e);
-        }
-        finally {
-            if (!success)
-                rollbackCurrentTx();
-        }
-    }
-
-    /**
-     *
-     * @param ctx Transaction context.
-     * @param key Key.
-     * @throws CacheException If failed.
-     */
-    private void unlock(TxContext ctx, Object key) throws CacheException {
-        if (ctx.unlocked(key)) { // Finish transaction if last key is unlocked.
-            txCtx.remove();
-
-            GridNearTxLocal tx = cache.tx();
-
-            assert tx != null;
-
-            try {
-                tx.proxy().commit();
-            }
-            finally {
-                tx.proxy().close();
-            }
-
-            assert cache.tx() == null;
-        }
-    }
-
-    /**
-     * Roll backs current transaction.
-     */
-    private void rollbackCurrentTx() {
-        try {
-            TxContext ctx = txCtx.get();
-
-            if (ctx != null) {
-                txCtx.remove();
-
-                GridNearTxLocal tx = cache.tx();
-
-                if (tx != null)
-                    tx.proxy().rollback();
-            }
-        }
-        catch (IgniteException e) {
-            log.error("Failed to rollback cache transaction.", e);
-        }
-    }
-
-    /**
-     * @param key Key.
-     * @throws IgniteCheckedException If failed.
-     */
-    private void lockKey(Object key) throws IgniteCheckedException {
-        if (cache.tx() == null)
-            cache.txStart(PESSIMISTIC, REPEATABLE_READ);
-
-        cache.get(key); // Acquire distributed lock.
-    }
-
-    /**
-     * Information about updates done during single database transaction.
-     */
-    @SuppressWarnings("TypeMayBeWeakened")
-    private static class TxContext {
-        /** */
-        private Set<Object> locked = new GridLeanSet<>();
-
-        /**
-         * Marks key as locked.
-         *
-         * @param key Key.
-         */
-        void locked(Object key) {
-            locked.add(key);
-        }
-
-        /**
-         * Marks key as unlocked.
-         *
-         * @param key Key.
-         * @return {@code True} if last locked key was unlocked.
-         */
-        boolean unlocked(Object key) {
-            locked.remove(key);
-
-            return locked.isEmpty();
-        }
-    }
-}
\ No newline at end of file


Mime
View raw message