IGNITE-9893 IGNITE-1757 IGNITE-10723 Adding hibernate-5.3 module
This change is based on the hibernate-5.1 module
updates to the module:
* added ability to allow for caches to be lazily loaded and created as a result
of post-bootstrap scanning. The module defaults to the same behavior as
the hibernate-5.1 module.
1. added org.apache.ignite.hibernate.verify_atomicity - relaxes the cache
atomicMode check
2. HibernateCacheProxy - now accepts a Supplier which lazily loads the
Ignite caches after the SPI is initialized
3. added org.apache.ignite.hibernate.cache_prefix - prepends all cache names
when a cache is looked up in ignite
4. removed dflt cache as ignite 2.x does not recommend mixed classes in one
cache
* all tests now pass as a result of fixing a couple bugs including IGNITE-1757
- Fixes #5008.
Signed-off-by: Ilya Kasnacheev <[email protected]>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/272858db
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/272858db
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/272858db
Branch: refs/heads/master
Commit: 272858dbc8b462f8bd345e3490d3767040379b5f
Parents: 9a1a830
Author: scottmf <[email protected]>
Authored: Wed Dec 19 17:04:28 2018 +0300
Committer: Ilya Kasnacheev <[email protected]>
Committed: Wed Dec 19 19:03:59 2018 +0300
----------------------------------------------------------------------
.../hibernate/CacheHibernateBlobStore.java | 6 +-
.../config/factory-incorrect-store-cache.xml | 4 +
.../HibernateL2CacheConfigurationSelfTest.java | 17 -
.../hibernate/HibernateL2CacheMultiJvmTest.java | 28 +-
.../CacheHibernateBlobStoreSelfTest.java | 4 -
.../CacheHibernateStoreFactorySelfTest.java | 2 -
.../hibernate/CacheHibernateBlobStore.java | 6 +-
.../config/factory-incorrect-store-cache.xml | 4 +
.../HibernateL2CacheConfigurationSelfTest.java | 17 -
.../hibernate/HibernateL2CacheMultiJvmTest.java | 27 +-
.../CacheHibernateBlobStoreSelfTest.java | 4 -
.../CacheHibernateStoreFactorySelfTest.java | 4 +-
modules/hibernate-5.3/licenses/apache-2.0.txt | 202 ++
modules/hibernate-5.3/pom.xml | 183 ++
.../cache/hibernate/HibernateKeyWrapper.java | 109 +
.../ignite/cache/hibernate/HibernateRegion.java | 74 +
.../cache/hibernate/HibernateRegionFactory.java | 154 ++
.../hibernate/IgniteCachedDomainDataAccess.java | 121 ++
.../hibernate/IgniteCollectionDataAccess.java | 61 +
.../cache/hibernate/IgniteDomainDataRegion.java | 182 ++
.../cache/hibernate/IgniteEntityDataAccess.java | 80 +
.../hibernate/IgniteGeneralDataRegion.java | 89 +
.../hibernate/IgniteNaturalIdDataAccess.java | 80 +
.../hibernate/IgniteQueryResultsRegion.java | 70 +
.../cache/hibernate/IgniteTimestampsRegion.java | 39 +
.../ignite/cache/hibernate/package-info.java | 24 +
.../hibernate/CacheHibernateBlobStore.java | 545 +++++
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 +
.../CacheHibernateBlobStoreFactory.java | 235 +++
.../CacheHibernateStoreSessionListener.java | 226 ++
.../cache/store/hibernate/package-info.java | 22 +
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 +
.../src/test/config/factory-cache.xml | 59 +
.../src/test/config/factory-cache1.xml | 61 +
.../config/factory-incorrect-store-cache.xml | 60 +
.../HibernateL2CacheConfigurationSelfTest.java | 409 ++++
.../hibernate/HibernateL2CacheMultiJvmTest.java | 441 ++++
.../hibernate/HibernateL2CacheSelfTest.java | 1991 ++++++++++++++++++
.../HibernateL2CacheStrategySelfTest.java | 570 +++++
.../HibernateL2CacheTransactionalSelfTest.java | 154 ++
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 +
.../CacheHibernateBlobStoreSelfTest.java | 118 ++
.../CacheHibernateStoreFactorySelfTest.java | 336 +++
...heHibernateStoreSessionListenerSelfTest.java | 242 +++
.../cache/store/hibernate/hibernate.cfg.xml | 41 +
.../cache/store/hibernate/package-info.java | 22 +
.../IgniteBinaryHibernate53TestSuite.java | 37 +
.../testsuites/IgniteHibernate53TestSuite.java | 61 +
.../cache/store/hibernate/hibernate.cfg.xml | 41 +
.../HibernateAccessStrategyAdapter.java | 18 +-
.../HibernateAccessStrategyFactory.java | 144 +-
.../cache/hibernate/HibernateCacheProxy.java | 266 +--
.../HibernateNonStrictAccessStrategy.java | 8 +-
.../HibernateReadOnlyAccessStrategy.java | 8 +-
.../HibernateReadWriteAccessStrategy.java | 40 +-
.../HibernateTransactionalAccessStrategy.java | 26 +-
pom.xml | 2 +
58 files changed, 7703 insertions(+), 268 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
index c87f08f..6658100 100644
---
a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
+++
b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
@@ -92,6 +92,9 @@ public class CacheHibernateBlobStore<K, V> extends
CacheStoreAdapter<K, V> {
/** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is
<tt>true</tt>). */
public static final String DFLT_HBM2DDL_AUTO = "update";
+ /** Default <tt>hibernate.connection.pool_size</tt> property value (value
is <tt>64</tt>). */
+ public static final String DFLT_CONN_POOL_SIZE = "64";
+
/** Session attribute name. */
private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
@@ -426,6 +429,7 @@ public class CacheHibernateBlobStore<K, V> extends
CacheStoreAdapter<K, V> {
hibernateProps.setProperty("hibernate.connection.url",
DFLT_CONN_URL);
hibernateProps.setProperty("hibernate.show_sql",
DFLT_SHOW_SQL);
hibernateProps.setProperty("hibernate.hbm2ddl.auto",
DFLT_HBM2DDL_AUTO);
+
hibernateProps.setProperty("hibernate.connection.pool_size",
DFLT_CONN_POOL_SIZE);
}
Configuration cfg = new Configuration();
@@ -539,4 +543,4 @@ public class CacheHibernateBlobStore<K, V> extends
CacheStoreAdapter<K, V> {
private CacheStoreSession session() {
return ses;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
----------------------------------------------------------------------
diff --git
a/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
b/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
index 459930c..4de9fc9 100644
--- a/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
+++ b/modules/hibernate-4.2/src/test/config/factory-incorrect-store-cache.xml
@@ -23,6 +23,10 @@
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="failureHandler">
+ <bean class="org.apache.ignite.failure.NoOpFailureHandler"/>
+ </property>
+
<property name="cacheConfiguration">
<list>
<bean
class="org.apache.ignite.configuration.CacheConfiguration">
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
index eb09c59..59b58c4 100644
---
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
+++
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
@@ -47,7 +47,6 @@ import org.junit.runners.JUnit4;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY;
-import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.IGNITE_INSTANCE_NAME_PROPERTY;
import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.REGION_CACHE_PROPERTY;
import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_FACTORY;
@@ -83,9 +82,6 @@ public class HibernateL2CacheConfigurationSelfTest extends
GridCommonAbstractTes
/** */
public static final String CONNECTION_URL =
"jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
- /** If {@code true} then sets default cache in configuration. */
- private boolean dfltCache;
-
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
startGrid(0);
@@ -163,9 +159,6 @@ public class HibernateL2CacheConfigurationSelfTest extends
GridCommonAbstractTes
cfg.setProperty(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE,
TIMESTAMP_CACHE);
cfg.setProperty(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);
- if (dfltCache)
- cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, "cache3");
-
return cfg;
}
@@ -178,16 +171,6 @@ public class HibernateL2CacheConfigurationSelfTest extends
GridCommonAbstractTes
}
/**
- * Tests property {@link
HibernateAccessStrategyFactory#DFLT_CACHE_NAME_PROPERTY}.
- */
- @Test
- public void testDefaultCache() {
- dfltCache = true;
-
- testCacheUsage(1, 1, 2, 0, 0);
- }
-
- /**
* @param expCache1 Expected size of cache with name 'cache1'.
* @param expCache2 Expected size of cache with name 'cache2'.
* @param expCache3 Expected size of cache with name 'cache3'.
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
index 43c54b2..e88962a 100644
---
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
+++
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
@@ -40,8 +40,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
import static
org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.CONNECTION_URL;
import static
org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.hibernateProperties;
import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
@@ -52,7 +53,7 @@ import static
org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
@RunWith(JUnit4.class)
public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest {
/** */
- private static final String CACHE_NAME = "hibernateCache";
+ private static final String TIMESTAMP_CACHE =
"org.hibernate.cache.spi.UpdateTimestampsCache";
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
@@ -61,12 +62,12 @@ public class HibernateL2CacheMultiJvmTest extends
GridCommonAbstractTest {
if (!getTestIgniteInstanceName(0).equals(igniteInstanceName))
cfg.setClientMode(true);
- CacheConfiguration ccfg = new CacheConfiguration();
-
- ccfg.setName(CACHE_NAME);
- ccfg.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setCacheConfiguration(ccfg);
+ cfg.setCacheConfiguration(
+ cacheConfiguration(TIMESTAMP_CACHE),
+ cacheConfiguration(Entity1.class.getName()),
+ cacheConfiguration(Entity2.class.getName()),
+ cacheConfiguration(Entity3.class.getName())
+ );
cfg.setMarshaller(new BinaryMarshaller());
@@ -75,6 +76,15 @@ public class HibernateL2CacheMultiJvmTest extends
GridCommonAbstractTest {
return cfg;
}
+ private CacheConfiguration cacheConfiguration(String cacheName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+ cfg.setName(cacheName);
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setAtomicityMode(ATOMIC);
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ return cfg;
+ }
+
/** {@inheritDoc} */
@Override protected boolean isMultiJvm() {
return true;
@@ -246,8 +256,6 @@ public class HibernateL2CacheMultiJvmTest extends
GridCommonAbstractTest {
for (Map.Entry<String, String> e : hibernateProperties(nodeName,
NONSTRICT_READ_WRITE.name()).entrySet())
cfg.setProperty(e.getKey(), e.getValue());
- cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, CACHE_NAME);
-
return cfg;
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
index 77025a1..f1b88d4 100644
---
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
+++
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
@@ -106,8 +106,4 @@ public class CacheHibernateBlobStoreSelfTest extends
// Store will be implicitly initialized.
store.load("key");
}
-
- @Override public void testSimpleMultithreading() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1757");
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
index e115551..a0663f3 100644
---
a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
+++
b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
@@ -90,8 +90,6 @@ public class CacheHibernateStoreFactorySelfTest extends
GridCommonAbstractTest {
*/
@Test
public void testIncorrectBeanConfiguration() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-10723");
-
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
try(Ignite ignite =
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
index 6e546b0..461af92 100644
---
a/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
+++
b/modules/hibernate-5.1/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
@@ -93,6 +93,9 @@ public class CacheHibernateBlobStore<K, V> extends
CacheStoreAdapter<K, V> {
/** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is
<tt>true</tt>). */
public static final String DFLT_HBM2DDL_AUTO = "update";
+ /** Default <tt>hibernate.connection.pool_size</tt> property value (value
is <tt>64</tt>). */
+ public static final String DFLT_CONN_POOL_SIZE = "64";
+
/** Session attribute name. */
private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
@@ -427,6 +430,7 @@ public class CacheHibernateBlobStore<K, V> extends
CacheStoreAdapter<K, V> {
hibernateProps.setProperty("hibernate.connection.url",
DFLT_CONN_URL);
hibernateProps.setProperty("hibernate.show_sql",
DFLT_SHOW_SQL);
hibernateProps.setProperty("hibernate.hbm2ddl.auto",
DFLT_HBM2DDL_AUTO);
+
hibernateProps.setProperty("hibernate.connection.pool_size",
DFLT_CONN_POOL_SIZE);
}
Configuration cfg = new Configuration();
@@ -540,4 +544,4 @@ public class CacheHibernateBlobStore<K, V> extends
CacheStoreAdapter<K, V> {
private CacheStoreSession session() {
return ses;
}
-}
\ No newline at end of file
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
b/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
index 459930c..4de9fc9 100644
--- a/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
+++ b/modules/hibernate-5.1/src/test/config/factory-incorrect-store-cache.xml
@@ -23,6 +23,10 @@
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="ignite.cfg"
class="org.apache.ignite.configuration.IgniteConfiguration">
+ <property name="failureHandler">
+ <bean class="org.apache.ignite.failure.NoOpFailureHandler"/>
+ </property>
+
<property name="cacheConfiguration">
<list>
<bean
class="org.apache.ignite.configuration.CacheConfiguration">
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
index f828d04..e8282b1 100644
---
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
+++
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheConfigurationSelfTest.java
@@ -46,7 +46,6 @@ import org.junit.runners.JUnit4;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.REGION_CACHE_PROPERTY;
import static org.hibernate.cfg.AvailableSettings.CACHE_REGION_FACTORY;
import static org.hibernate.cfg.AvailableSettings.GENERATE_STATISTICS;
@@ -81,9 +80,6 @@ public class HibernateL2CacheConfigurationSelfTest extends
GridCommonAbstractTes
/** */
public static final String CONNECTION_URL =
"jdbc:h2:mem:example;DB_CLOSE_DELAY=-1";
- /** If {@code true} then sets default cache in configuration. */
- private boolean dfltCache;
-
/** {@inheritDoc} */
@Override protected void beforeTestsStarted() throws Exception {
startGrid(0);
@@ -160,9 +156,6 @@ public class HibernateL2CacheConfigurationSelfTest extends
GridCommonAbstractTes
cfg.setProperty(REGION_CACHE_PROPERTY + TIMESTAMP_CACHE,
TIMESTAMP_CACHE);
cfg.setProperty(REGION_CACHE_PROPERTY + QUERY_CACHE, QUERY_CACHE);
- if (dfltCache)
- cfg.setProperty(DFLT_CACHE_NAME_PROPERTY, "cache3");
-
return cfg;
}
@@ -175,16 +168,6 @@ public class HibernateL2CacheConfigurationSelfTest extends
GridCommonAbstractTes
}
/**
- * Tests property {@link
HibernateAccessStrategyFactory#DFLT_CACHE_NAME_PROPERTY}.
- */
- @Test
- public void testDefaultCache() {
- dfltCache = true;
-
- testCacheUsage(1, 1, 2, 0, 0);
- }
-
- /**
* @param expCache1 Expected size of cache with name 'cache1'.
* @param expCache2 Expected size of cache with name 'cache2'.
* @param expCache3 Expected size of cache with name 'cache3'.
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
index b3da8bb..e712484 100644
---
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
+++
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheMultiJvmTest.java
@@ -40,8 +40,9 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
-import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_CACHE_NAME_PROPERTY;
import static
org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.CONNECTION_URL;
import static
org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest.hibernateProperties;
import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
@@ -52,7 +53,7 @@ import static
org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
@RunWith(JUnit4.class)
public class HibernateL2CacheMultiJvmTest extends GridCommonAbstractTest {
/** */
- private static final String CACHE_NAME = "hibernateCache";
+ private static final String TIMESTAMP_CACHE =
"org.hibernate.cache.spi.UpdateTimestampsCache";
/** {@inheritDoc} */
@Override protected IgniteConfiguration getConfiguration(String
igniteInstanceName) throws Exception {
@@ -61,12 +62,12 @@ public class HibernateL2CacheMultiJvmTest extends
GridCommonAbstractTest {
if (!getTestIgniteInstanceName(0).equals(igniteInstanceName))
cfg.setClientMode(true);
- CacheConfiguration ccfg = new CacheConfiguration();
-
- ccfg.setName(CACHE_NAME);
- ccfg.setWriteSynchronizationMode(FULL_SYNC);
-
- cfg.setCacheConfiguration(ccfg);
+ cfg.setCacheConfiguration(
+ cacheConfiguration(TIMESTAMP_CACHE),
+ cacheConfiguration(Entity1.class.getName()),
+ cacheConfiguration(Entity2.class.getName()),
+ cacheConfiguration(Entity3.class.getName())
+ );
cfg.setMarshaller(new BinaryMarshaller());
@@ -75,6 +76,15 @@ public class HibernateL2CacheMultiJvmTest extends
GridCommonAbstractTest {
return cfg;
}
+ private CacheConfiguration cacheConfiguration(String cacheName) {
+ CacheConfiguration cfg = new CacheConfiguration();
+ cfg.setName(cacheName);
+ cfg.setCacheMode(PARTITIONED);
+ cfg.setAtomicityMode(ATOMIC);
+ cfg.setWriteSynchronizationMode(FULL_SYNC);
+ return cfg;
+ }
+
/** {@inheritDoc} */
@Override protected boolean isMultiJvm() {
return true;
@@ -229,7 +239,6 @@ public class HibernateL2CacheMultiJvmTest extends
GridCommonAbstractTest {
builder.applySetting(e.getKey(), e.getValue());
builder.applySetting("hibernate.connection.url", CONNECTION_URL);
- builder.applySetting(DFLT_CACHE_NAME_PROPERTY, CACHE_NAME);
MetadataSources metadataSources = new
MetadataSources(builder.build());
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
index 9deaeec..83dd6e8 100644
---
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
+++
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
@@ -115,8 +115,4 @@ public class CacheHibernateBlobStoreSelfTest extends
store.load("key");
}
- @Test
- @Override public void testSimpleMultithreading() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-1757");
- }
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
index 86a058b..f1ea2be 100644
---
a/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
+++
b/modules/hibernate-5.1/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreFactorySelfTest.java
@@ -90,11 +90,9 @@ public class CacheHibernateStoreFactorySelfTest extends
GridCommonAbstractTest {
*/
@Test
public void testIncorrectBeanConfiguration() throws Exception {
- fail("https://issues.apache.org/jira/browse/IGNITE-10723");
-
GridTestUtils.assertThrows(log, new Callable<Object>() {
@Override public Object call() throws Exception {
- try(Ignite ignite =
+ try (Ignite ignite =
Ignition.start(MODULE_PATH +
"/src/test/config/factory-incorrect-store-cache.xml")) {
ignite.cache(CACHE_NAME).getConfiguration(CacheConfiguration.class).
getCacheStoreFactory().create();
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.3/licenses/apache-2.0.txt
b/modules/hibernate-5.3/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/hibernate-5.3/licenses/apache-2.0.txt
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-5.3/pom.xml b/modules/hibernate-5.3/pom.xml
new file mode 100644
index 0000000..9e87de5
--- /dev/null
+++ b/modules/hibernate-5.3/pom.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-hibernate_5.3</artifactId>
+ <version>2.7.0-SNAPSHOT</version>
+ <url>http://ignite.apache.org</url>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>5.3.7.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-jta</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.ow2.jotm</groupId>
+ <artifactId>jotm-core</artifactId>
+ <version>2.1.9</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-dbcp</groupId>
+ <artifactId>commons-dbcp</artifactId>
+ <version>1.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>${h2.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <version>1.5</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-spring</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-log4j</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ <version>${spring.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.8</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>lgpl</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>false</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <testResources>
+ <testResource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <!-- Generate the OSGi MANIFEST.MF for this bundle. -->
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
new file mode 100644
index 0000000..45d00e4
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
@@ -0,0 +1,109 @@
+/*
+ * 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.Serializable;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.hibernate.cache.internal.DefaultCacheKeysFactory;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.persister.entity.EntityPersister;
+
+/**
+ * Hibernate cache key wrapper.
+ */
+public class HibernateKeyWrapper implements Serializable {
+ /** Key. */
+ private final Object key;
+
+ /** Entry. */
+ private final String entry;
+
+ /** */
+ private final String tenantId;
+
+ /**
+ * @param key Key.
+ * @param entry Entry.
+ * @param tenantId Tenant ID.
+ */
+ HibernateKeyWrapper(Object key, String entry, String tenantId) {
+ this.key = key;
+ this.entry = entry;
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * @return ID.
+ */
+ Object id() {
+ return key;
+ }
+
+ /**
+ * @param id ID.
+ * @param persister Persister.
+ * @param tenantIdentifier Tenant ID.
+ * @return Cache key.
+ * @see DefaultCacheKeysFactory#staticCreateCollectionKey(Object,
CollectionPersister, SessionFactoryImplementor, String)
+ */
+ static Object staticCreateCollectionKey(Object id,
+ CollectionPersister persister,
+ String tenantIdentifier) {
+ return new HibernateKeyWrapper(id, persister.getRole(),
tenantIdentifier);
+ }
+
+ /**
+ * @param id ID.
+ * @param persister Persister.
+ * @param tenantIdentifier Tenant ID.
+ * @return Cache key.
+ * @see DefaultCacheKeysFactory#staticCreateEntityKey(Object,
EntityPersister, SessionFactoryImplementor, String)
+ */
+ public static Object staticCreateEntityKey(Object id, EntityPersister
persister, String tenantIdentifier) {
+ return new HibernateKeyWrapper(id, persister.getRootEntityName(),
tenantIdentifier);
+ }
+
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o) return true;
+
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ HibernateKeyWrapper that = (HibernateKeyWrapper) o;
+
+ return (key != null ? key.equals(that.key) : that.key == null) &&
+ (entry != null ? entry.equals(that.entry) : that.entry == null) &&
+ (tenantId != null ? tenantId.equals(that.tenantId) : that.tenantId
== null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = key != null ? key.hashCode() : 0;
+ res = 31 * res + (entry != null ? entry.hashCode() : 0);
+ res = 31 * res + (tenantId != null ? tenantId.hashCode() : 0);
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return S.toString(HibernateKeyWrapper.class, this);
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
new file mode 100644
index 0000000..184196e
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
@@ -0,0 +1,74 @@
+/*
+ * 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.ExtendedStatisticsSupport;
+import org.hibernate.cache.spi.Region;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.support.AbstractRegion;
+
+/**
+ * Implementation of {@link Region}. This interface defines base contract for
all L2 cache regions.
+ */
+public abstract class HibernateRegion extends AbstractRegion implements
ExtendedStatisticsSupport {
+ /** Cache instance. */
+ protected final HibernateCacheProxy cache;
+
+ /** Grid instance. */
+ protected Ignite ignite;
+
+ /** */
+ protected HibernateRegion(RegionFactory factory, String name, Ignite
ignite, HibernateCacheProxy cache) {
+ super(name, factory);
+
+ this.ignite = ignite;
+ this.cache = cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clear() {
+ try {
+ cache.clear();
+ } catch (IgniteCheckedException e) {
+ throw new CacheException("Problem clearing cache [name=" +
cache.name() + "]", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroy() throws CacheException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountInMemory() {
+ return cache.offHeapEntriesCount();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountOnDisk() {
+ return cache.sizeLong();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getSizeInMemory() {
+ return cache.offHeapAllocatedSize();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
new file mode 100644
index 0000000..b47cb74
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
@@ -0,0 +1,154 @@
+/*
+ * 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.time.Instant;
+import java.util.Map;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.hibernate.boot.spi.SessionFactoryOptions;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.cfg.spi.DomainDataRegionBuildingContext;
+import org.hibernate.cache.cfg.spi.DomainDataRegionConfig;
+import org.hibernate.cache.spi.DomainDataRegion;
+import org.hibernate.cache.spi.QueryResultsRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.TimestampsRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.support.RegionNameQualifier;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+
+import static
org.apache.ignite.cache.hibernate.HibernateAccessStrategyFactory.DFLT_ACCESS_TYPE_PROPERTY;
+import static org.hibernate.cache.spi.access.AccessType.NONSTRICT_READ_WRITE;
+
+/**
+ * Hibernate L2 cache region factory.
+ * <p>
+ * Following Hibernate settings should be specified to enable second level
cache and to use this
+ * region factory for caching:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * hibernate.cache.use_second_level_cache=true
+ *
hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
+ * </pre>
+ * Note that before region factory is started you need to start properly
configured Ignite node in the same JVM.
+ * For example to start Ignite node one of loader provided in {@code
org.apache.ignite.grid.startup} package can be used.
+ * <p>
+ * Name of Ignite instance to be used for region factory must be specified as
following Hibernate property:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * org.apache.ignite.hibernate.ignite_instance_name=<Ignite instance
name>
+ * </pre>
+ * Each Hibernate cache region must be associated with some {@link
IgniteInternalCache}, by default it is assumed that
+ * for each cache region there is a {@link IgniteInternalCache} with the same
name. Also it is possible to define
+ * region to cache mapping using properties with prefix {@code
org.apache.ignite.hibernate.region_cache}.
+ * For example if for region with name "region1" cache with name "cache1"
should be used then following
+ * Hibernate property should be specified:
+ * <pre name="code" class="brush: xml; gutter: false;">
+ * org.apache.ignite.hibernate.region_cache.region1=cache1
+ * </pre>
+ */
+public class HibernateRegionFactory implements RegionFactory {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** */
+ static final HibernateExceptionConverter EXCEPTION_CONVERTER = new
HibernateExceptionConverter() {
+ @Override public RuntimeException convert(Exception e) {
+ return new CacheException(e);
+ }
+ };
+
+ /** Default region access type. */
+ private AccessType dfltAccessType;
+
+ /** Key transformer. */
+ private final HibernateKeyTransformer hibernate4transformer = new
HibernateKeyTransformer() {
+ @Override public Object transform(Object key) {
+ return key;
+ }
+ };
+
+ /** */
+ private final HibernateAccessStrategyFactory accessStgyFactory =
+ new HibernateAccessStrategyFactory(hibernate4transformer,
EXCEPTION_CONVERTER);
+
+ /** */
+ private SessionFactoryOptions options;
+
+ /** {@inheritDoc} */
+ @Override public void start(SessionFactoryOptions options, Map cfgValues)
throws CacheException {
+ this.options = options;
+
+ String accessType = cfgValues.getOrDefault(
+ DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name()).toString();
+
+ dfltAccessType = AccessType.valueOf(accessType);
+
+ accessStgyFactory.start(cfgValues);
+ }
+
+ /**
+ * @return Access strategy factory.
+ */
+ HibernateAccessStrategyFactory accessStrategyFactory() {
+ return accessStgyFactory;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isMinimalPutsEnabledByDefault() {
+ return false;
+ }
+
+ /** {@inheritDoc} */
+ @Override public AccessType getDefaultAccessType() {
+ return dfltAccessType;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long nextTimestamp() {
+ return Instant.now().toEpochMilli();
+ }
+
+ /** {@inheritDoc} */
+ @Override public String qualify(String regionName) {
+ return RegionNameQualifier.INSTANCE.qualify(regionName, options);
+ }
+
+ /** {@inheritDoc} */
+ @Override public DomainDataRegion buildDomainDataRegion(
+ DomainDataRegionConfig regionCfg,
+ DomainDataRegionBuildingContext buildingCtx) {
+ return new IgniteDomainDataRegion(regionCfg, this, null, buildingCtx,
+ accessStgyFactory);
+ }
+
+ /** {@inheritDoc} */
+ @Override public QueryResultsRegion buildQueryResultsRegion(String
regionName, SessionFactoryImplementor sessFactory) {
+ return new IgniteQueryResultsRegion(this, regionName,
accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+
+ /** {@inheritDoc} */
+ @Override public TimestampsRegion buildTimestampsRegion(String regionName,
SessionFactoryImplementor sessFactory) {
+ return new IgniteTimestampsRegion(this, regionName,
accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCachedDomainDataAccess.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCachedDomainDataAccess.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCachedDomainDataAccess.java
new file mode 100644
index 0000000..4003418
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCachedDomainDataAccess.java
@@ -0,0 +1,121 @@
+/*
+ * 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.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.DomainDataRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.access.CachedDomainDataAccess;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.hibernate.engine.spi.SharedSessionContractImplementor;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of L2 cache access strategy delegating to {@link
HibernateAccessStrategyAdapter}.
+ */
+public abstract class IgniteCachedDomainDataAccess extends HibernateRegion
implements CachedDomainDataAccess {
+ /** */
+ protected final HibernateAccessStrategyAdapter stgy;
+
+ /** */
+ private DomainDataRegion domainDataRegion;
+
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ protected IgniteCachedDomainDataAccess(HibernateAccessStrategyAdapter stgy,
+ RegionFactory regionFactory,
+ DomainDataRegion domainDataRegion,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(regionFactory, cache.name(), ignite, cache);
+
+ this.stgy = stgy;
+ this.domainDataRegion = domainDataRegion;
+ }
+
+ /** {@inheritDoc} */
+ @Override public DomainDataRegion getRegion() {
+ return domainDataRegion;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Object get(SharedSessionContractImplementor ses, Object
key) throws CacheException {
+ return stgy.get(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(SharedSessionContractImplementor ses,
Object key, Object value, Object version) throws CacheException {
+ stgy.putFromLoad(key, value);
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(SharedSessionContractImplementor ses,
Object key, Object value, Object version, boolean minimalPutOverride) throws
CacheException {
+ stgy.putFromLoad(key, value);
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public SoftLock lockItem(SharedSessionContractImplementor ses,
Object key, Object version) throws CacheException {
+ stgy.lock(key);
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlockItem(SharedSessionContractImplementor ses,
Object key, SoftLock lock) throws CacheException {
+ stgy.unlock(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(SharedSessionContractImplementor ses, Object
key) throws CacheException {
+ stgy.remove(key);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public SoftLock lockRegion() throws CacheException {
+ stgy.lockRegion();
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void unlockRegion(SoftLock lock) throws CacheException {
+ stgy.unlockRegion();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAll(SharedSessionContractImplementor ses)
throws CacheException {
+ stgy.removeAll();
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Object key) throws CacheException {
+ stgy.evict(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictAll() throws CacheException {
+ stgy.evictAll();
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean contains(Object key) {
+ return stgy.get(key) != null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCollectionDataAccess.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCollectionDataAccess.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCollectionDataAccess.java
new file mode 100644
index 0000000..aabe32e
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteCollectionDataAccess.java
@@ -0,0 +1,61 @@
+/*
+ * 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.hibernate.cache.spi.DomainDataRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.CollectionDataAccess;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.persister.collection.CollectionPersister;
+
+/** */
+public class IgniteCollectionDataAccess extends IgniteCachedDomainDataAccess
implements CollectionDataAccess {
+ /** */
+ private final AccessType accessType;
+
+ /** */
+ public IgniteCollectionDataAccess(HibernateAccessStrategyAdapter stgy,
AccessType accessType,
+ RegionFactory regionFactory,
+ DomainDataRegion domainDataRegion, Ignite ignite,
+ HibernateCacheProxy cache) {
+ super(stgy, regionFactory, domainDataRegion, ignite, cache);
+
+ this.accessType = accessType;
+ }
+
+ /** */
+ @Override public AccessType getAccessType() {
+ return accessType;
+ }
+
+ /** */
+ @Override public Object generateCacheKey(
+ Object id,
+ CollectionPersister persister,
+ SessionFactoryImplementor factory,
+ String tenantIdentifier) {
+ return HibernateKeyWrapper.staticCreateCollectionKey(id, persister,
tenantIdentifier);
+ }
+
+ /** */
+ @Override public Object getCacheKeyId(Object cacheKey) {
+ return ((HibernateKeyWrapper)cacheKey).id();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteDomainDataRegion.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteDomainDataRegion.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteDomainDataRegion.java
new file mode 100644
index 0000000..c422a52
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteDomainDataRegion.java
@@ -0,0 +1,182 @@
+/*
+ * 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.hibernate.cache.CacheException;
+import org.hibernate.cache.cfg.spi.CollectionDataCachingConfig;
+import org.hibernate.cache.cfg.spi.DomainDataRegionBuildingContext;
+import org.hibernate.cache.cfg.spi.DomainDataRegionConfig;
+import org.hibernate.cache.cfg.spi.EntityDataCachingConfig;
+import org.hibernate.cache.cfg.spi.NaturalIdDataCachingConfig;
+import org.hibernate.cache.spi.CacheKeysFactory;
+import org.hibernate.cache.spi.ExtendedStatisticsSupport;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.CollectionDataAccess;
+import org.hibernate.cache.spi.access.EntityDataAccess;
+import org.hibernate.cache.spi.access.NaturalIdDataAccess;
+import org.hibernate.cache.spi.support.AbstractDomainDataRegion;
+
+/** */
+public class IgniteDomainDataRegion extends AbstractDomainDataRegion
implements ExtendedStatisticsSupport {
+ /** */
+ private final HibernateCacheProxy cache;
+
+ /** */
+ private HibernateAccessStrategyFactory stgyFactory;
+
+ /** */
+ public IgniteDomainDataRegion(DomainDataRegionConfig regionCfg,
+ RegionFactory regionFactory,
+ CacheKeysFactory defKeysFactory,
+ DomainDataRegionBuildingContext buildingCtx,
+ HibernateAccessStrategyFactory stgyFactory) {
+ super(regionCfg, regionFactory, defKeysFactory, buildingCtx);
+
+ this.stgyFactory = stgyFactory;
+
+ cache = stgyFactory.regionCache(getName());
+
+ completeInstantiation(regionCfg, buildingCtx);
+ }
+
+ /** */
+ @Override protected EntityDataAccess
generateEntityAccess(EntityDataCachingConfig entityAccessCfg) {
+ AccessType accessType = entityAccessCfg.getAccessType();
+ Ignite ignite = stgyFactory.node();
+ switch (accessType) {
+ case READ_ONLY:
+ HibernateAccessStrategyAdapter readOnlyStgy =
+ stgyFactory.createReadOnlyStrategy(cache);
+ return new IgniteEntityDataAccess(readOnlyStgy, accessType,
getRegionFactory(),
+ this, ignite, cache);
+
+ case NONSTRICT_READ_WRITE:
+ HibernateAccessStrategyAdapter nonStrictReadWriteStgy =
+ stgyFactory.createNonStrictReadWriteStrategy(cache);
+ return new IgniteEntityDataAccess(nonStrictReadWriteStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ case READ_WRITE:
+ HibernateAccessStrategyAdapter readWriteStgy =
+ stgyFactory.createReadWriteStrategy(cache);
+ return new IgniteEntityDataAccess(readWriteStgy, accessType,
getRegionFactory(),
+ this, ignite, cache);
+
+ case TRANSACTIONAL:
+ HibernateAccessStrategyAdapter transactionalStgy =
+ stgyFactory.createTransactionalStrategy(cache);
+ return new IgniteEntityDataAccess(transactionalStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ default:
+ throw new IllegalArgumentException("Unknown Hibernate access
type: " + accessType);
+ }
+ }
+
+ /** */
+ @Override protected CollectionDataAccess
generateCollectionAccess(CollectionDataCachingConfig cachingCfg) {
+ HibernateCacheProxy cache = stgyFactory.regionCache(getName());
+ AccessType accessType = cachingCfg.getAccessType();
+ Ignite ignite = stgyFactory.node();
+ switch (accessType) {
+ case READ_ONLY:
+ HibernateAccessStrategyAdapter readOnlyStgy =
+ stgyFactory.createReadOnlyStrategy(cache);
+ return new IgniteCollectionDataAccess(readOnlyStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ case NONSTRICT_READ_WRITE:
+ HibernateAccessStrategyAdapter nonStrictReadWriteStgy =
+ stgyFactory.createNonStrictReadWriteStrategy(cache);
+ return new IgniteCollectionDataAccess(nonStrictReadWriteStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ case READ_WRITE:
+ HibernateAccessStrategyAdapter readWriteStgy =
+ stgyFactory.createReadWriteStrategy(cache);
+ return new IgniteCollectionDataAccess(readWriteStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ case TRANSACTIONAL:
+ HibernateAccessStrategyAdapter transactionalStgy =
+ stgyFactory.createTransactionalStrategy(cache);
+ return new IgniteCollectionDataAccess(transactionalStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ default:
+ throw new IllegalArgumentException("Unknown Hibernate access
type: " + accessType);
+ }
+ }
+
+ /** */
+ @Override protected NaturalIdDataAccess
generateNaturalIdAccess(NaturalIdDataCachingConfig naturalIdAccessCfg) {
+ HibernateCacheProxy cache = stgyFactory.regionCache(getName());
+ AccessType accessType = naturalIdAccessCfg.getAccessType();
+ Ignite ignite = stgyFactory.node();
+ switch (accessType) {
+ case READ_ONLY:
+ HibernateAccessStrategyAdapter readOnlyStgy =
+ stgyFactory.createReadOnlyStrategy(cache);
+ return new IgniteNaturalIdDataAccess(readOnlyStgy, accessType,
getRegionFactory(),
+ this, ignite, cache);
+
+ case NONSTRICT_READ_WRITE:
+ HibernateAccessStrategyAdapter nonStrictReadWriteStgy =
+ stgyFactory.createNonStrictReadWriteStrategy(cache);
+ return new IgniteNaturalIdDataAccess(nonStrictReadWriteStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ case READ_WRITE:
+ HibernateAccessStrategyAdapter readWriteStgy =
+ stgyFactory.createReadWriteStrategy(cache);
+ return new IgniteNaturalIdDataAccess(readWriteStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ case TRANSACTIONAL:
+ HibernateAccessStrategyAdapter transactionalStgy =
+ stgyFactory.createTransactionalStrategy(cache);
+ return new IgniteNaturalIdDataAccess(transactionalStgy,
accessType, getRegionFactory(),
+ this, ignite, cache);
+
+ default:
+ throw new IllegalArgumentException("Unknown Hibernate access
type: " + accessType);
+ }
+ }
+
+ /** */
+ @Override public void destroy() throws CacheException {
+ // no-op
+ }
+
+ /** */
+ @Override public long getElementCountInMemory() {
+ return cache.offHeapEntriesCount();
+ }
+
+ /** */
+ @Override public long getElementCountOnDisk() {
+ return cache.sizeLong();
+ }
+
+ /** */
+ @Override public long getSizeInMemory() {
+ return cache.offHeapAllocatedSize();
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteEntityDataAccess.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteEntityDataAccess.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteEntityDataAccess.java
new file mode 100644
index 0000000..54fad42
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteEntityDataAccess.java
@@ -0,0 +1,80 @@
+/*
+ * 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.hibernate.cache.spi.DomainDataRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.EntityDataAccess;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.engine.spi.SharedSessionContractImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+
+/** */
+public class IgniteEntityDataAccess extends IgniteCachedDomainDataAccess
implements EntityDataAccess {
+ /** */
+ private final AccessType accessType;
+
+ /** */
+ public IgniteEntityDataAccess(HibernateAccessStrategyAdapter stgy,
AccessType accessType,
+ RegionFactory regionFactory,
+ DomainDataRegion domainDataRegion, Ignite ignite,
+ HibernateCacheProxy cache) {
+ super(stgy, regionFactory, domainDataRegion, ignite, cache);
+
+ this.accessType = accessType;
+ }
+
+ /** */
+ @Override public Object generateCacheKey(Object id, EntityPersister
persister, SessionFactoryImplementor factory,
+ String tenantIdentifier) {
+ return HibernateKeyWrapper.staticCreateEntityKey(id, persister,
tenantIdentifier);
+ }
+
+ /** */
+ @Override public Object getCacheKeyId(Object cacheKey) {
+ return ((HibernateKeyWrapper) cacheKey).id();
+ }
+
+ /** */
+ @Override public boolean insert(SharedSessionContractImplementor ses,
Object key, Object val, Object ver) {
+ return stgy.insert(key, val);
+ }
+
+ /** */
+ @Override public boolean afterInsert(SharedSessionContractImplementor ses,
Object key, Object val, Object ver) {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** */
+ @Override public boolean update(SharedSessionContractImplementor ses,
Object key, Object val, Object curVer, Object prevVer) {
+ return stgy.update(key, val);
+ }
+
+ /** */
+ @Override public boolean afterUpdate(SharedSessionContractImplementor ses,
Object key, Object val, Object curVer, Object prevVer, SoftLock lock) {
+ return stgy.afterUpdate(key, val);
+ }
+
+ /** */
+ @Override public AccessType getAccessType() {
+ return accessType;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteGeneralDataRegion.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteGeneralDataRegion.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteGeneralDataRegion.java
new file mode 100644
index 0000000..4762054
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteGeneralDataRegion.java
@@ -0,0 +1,89 @@
+/*
+ * 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.apache.ignite.IgniteLogger;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.DirectAccessRegion;
+import org.hibernate.cache.spi.QueryResultsRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.TimestampsRegion;
+import org.hibernate.engine.spi.SharedSessionContractImplementor;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of {@link DirectAccessRegion}. This interface defines common
contract for {@link QueryResultsRegion}
+ * and {@link TimestampsRegion}.
+ */
+public class IgniteGeneralDataRegion extends HibernateRegion implements
DirectAccessRegion {
+ /** */
+ private final IgniteLogger log;
+
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ IgniteGeneralDataRegion(RegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+
+ log = ignite.log().getLogger(getClass());
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object getFromCache(Object key,
SharedSessionContractImplementor ses) throws CacheException {
+ try {
+ Object val = cache.get(key);
+
+ if (log.isDebugEnabled())
+ log.debug("Get [cache=" + cache.name() + ", key=" + key + ",
val=" + val + ']');
+
+ return val;
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void putIntoCache(Object key, Object val,
SharedSessionContractImplementor ses) throws CacheException {
+ try {
+ cache.put(key, val);
+
+ if (log.isDebugEnabled())
+ log.debug("Put [cache=" + cache.name() + ", key=" + key + ",
val=" + val + ']');
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void clear() {
+ try {
+ cache.clear();
+ }
+ catch (IgniteCheckedException e) {
+ throw new CacheException("Problem clearing cache [name=" +
cache.name() + "]", e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/272858db/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteNaturalIdDataAccess.java
----------------------------------------------------------------------
diff --git
a/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteNaturalIdDataAccess.java
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteNaturalIdDataAccess.java
new file mode 100644
index 0000000..aa11ce5
--- /dev/null
+++
b/modules/hibernate-5.3/src/main/java/org/apache/ignite/cache/hibernate/IgniteNaturalIdDataAccess.java
@@ -0,0 +1,80 @@
+/*
+ * 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.hibernate.cache.CacheException;
+import org.hibernate.cache.internal.DefaultCacheKeysFactory;
+import org.hibernate.cache.spi.DomainDataRegion;
+import org.hibernate.cache.spi.RegionFactory;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.NaturalIdDataAccess;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.hibernate.engine.spi.SharedSessionContractImplementor;
+import org.hibernate.persister.entity.EntityPersister;
+
+/** */
+public class IgniteNaturalIdDataAccess extends IgniteCachedDomainDataAccess
implements NaturalIdDataAccess {
+ /** */
+ private final AccessType accessType;
+
+ /** */
+ public IgniteNaturalIdDataAccess(HibernateAccessStrategyAdapter stgy,
AccessType accessType,
+ RegionFactory regionFactory,
+ DomainDataRegion domainDataRegion, Ignite ignite,
+ HibernateCacheProxy cache) {
+ super(stgy, regionFactory, domainDataRegion, ignite, cache);
+
+ this.accessType = accessType;
+ }
+
+ /** */
+ @Override public AccessType getAccessType() {
+ return accessType;
+ }
+
+ /** */
+ @Override public Object generateCacheKey(Object[] naturalIdValues,
EntityPersister persister, SharedSessionContractImplementor ses) {
+ return
DefaultCacheKeysFactory.staticCreateNaturalIdKey(naturalIdValues, persister,
ses);
+ }
+
+ /** */
+ @Override public Object[] getNaturalIdValues(Object cacheKey) {
+ return DefaultCacheKeysFactory.staticGetNaturalIdValues(cacheKey);
+ }
+
+ /** */
+ @Override public boolean insert(SharedSessionContractImplementor ses,
Object key, Object val) throws CacheException {
+ return stgy.insert(key, val);
+ }
+
+ /** */
+ @Override public boolean afterInsert(SharedSessionContractImplementor ses,
Object key, Object val) throws CacheException {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** */
+ @Override public boolean update(SharedSessionContractImplementor ses,
Object key, Object val) throws CacheException {
+ return stgy.update(key, val);
+ }
+
+ /** */
+ @Override public boolean afterUpdate(SharedSessionContractImplementor ses,
Object key, Object val, SoftLock lock) throws CacheException {
+ return stgy.afterUpdate(key, val);
+ }
+}