You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2017/04/26 13:25:55 UTC
[44/50] [abbrv] ignite git commit: ignite-1794 Refactored hibernate
modules, switched to hibernate 5.1
ignite-1794 Refactored hibernate modules, switched to hibernate 5.1
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ee1b19d3
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ee1b19d3
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ee1b19d3
Branch: refs/heads/master
Commit: ee1b19d3f6eb8c07405ee6783379d4c2c20ad8c8
Parents: c9cd761
Author: sboikov <sb...@gridgain.com>
Authored: Wed Apr 26 14:18:01 2017 +0300
Committer: sboikov <sb...@gridgain.com>
Committed: Wed Apr 26 14:18:14 2017 +0300
----------------------------------------------------------------------
assembly/dependencies-fabric.xml | 5 +-
examples/pom-standalone-lgpl.xml | 2 +-
examples/pom-standalone.xml | 2 +-
examples/pom.xml | 38 +-
.../hibernate/HibernateL2CacheExample.java | 12 +-
modules/hibernate-4.2/README.txt | 48 +
modules/hibernate-4.2/licenses/apache-2.0.txt | 202 ++
modules/hibernate-4.2/pom.xml | 159 ++
.../HibernateAbstractRegionAccessStrategy.java | 102 +
.../hibernate/HibernateCollectionRegion.java | 100 +
.../cache/hibernate/HibernateEntityRegion.java | 112 +
.../hibernate/HibernateGeneralDataRegion.java | 76 +
.../cache/hibernate/HibernateKeyWrapper.java | 73 +
.../hibernate/HibernateNaturalIdRegion.java | 103 +
.../hibernate/HibernateQueryResultsRegion.java | 70 +
.../ignite/cache/hibernate/HibernateRegion.java | 99 +
.../cache/hibernate/HibernateRegionFactory.java | 179 ++
.../hibernate/HibernateTimestampsRegion.java | 39 +
.../HibernateTransactionalDataRegion.java | 84 +
.../ignite/cache/hibernate/package-info.java | 24 +
.../hibernate/CacheHibernateBlobStore.java | 542 +++++
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 +
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 +
.../CacheHibernateBlobStoreFactory.java | 235 +++
.../CacheHibernateStoreSessionListener.java | 222 ++
.../cache/store/hibernate/package-info.java | 22 +
.../src/test/config/factory-cache.xml | 59 +
.../src/test/config/factory-cache1.xml | 61 +
.../config/factory-incorrect-store-cache.xml | 56 +
.../HibernateL2CacheConfigurationSelfTest.java | 409 ++++
.../hibernate/HibernateL2CacheMultiJvmTest.java | 440 ++++
.../hibernate/HibernateL2CacheSelfTest.java | 1954 +++++++++++++++++
.../HibernateL2CacheTransactionalSelfTest.java | 154 ++
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 +
.../CacheHibernateBlobStoreSelfTest.java | 113 +
.../CacheHibernateStoreFactorySelfTest.java | 288 +++
...heHibernateStoreSessionListenerSelfTest.java | 238 +++
.../cache/store/hibernate/hibernate.cfg.xml | 42 +
.../cache/store/hibernate/package-info.java | 22 +
.../IgniteBinaryHibernateTestSuite.java | 37 +
.../testsuites/IgniteHibernateTestSuite.java | 57 +
modules/hibernate-5.1/README.txt | 48 +
modules/hibernate-5.1/licenses/apache-2.0.txt | 202 ++
modules/hibernate-5.1/pom.xml | 159 ++
.../HibernateAbstractRegionAccessStrategy.java | 103 +
.../hibernate/HibernateCollectionRegion.java | 114 +
.../cache/hibernate/HibernateEntityRegion.java | 128 ++
.../hibernate/HibernateGeneralDataRegion.java | 79 +
.../cache/hibernate/HibernateKeyWrapper.java | 109 +
.../hibernate/HibernateNaturalIdRegion.java | 113 +
.../hibernate/HibernateQueryResultsRegion.java | 70 +
.../ignite/cache/hibernate/HibernateRegion.java | 99 +
.../cache/hibernate/HibernateRegionFactory.java | 168 ++
.../hibernate/HibernateTimestampsRegion.java | 39 +
.../HibernateTransactionalDataRegion.java | 84 +
.../ignite/cache/hibernate/package-info.java | 24 +
.../hibernate/CacheHibernateBlobStore.java | 543 +++++
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 +
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 +
.../CacheHibernateBlobStoreFactory.java | 235 +++
.../CacheHibernateStoreSessionListener.java | 224 ++
.../cache/store/hibernate/package-info.java | 22 +
.../src/test/config/factory-cache.xml | 59 +
.../src/test/config/factory-cache1.xml | 61 +
.../config/factory-incorrect-store-cache.xml | 56 +
.../HibernateL2CacheConfigurationSelfTest.java | 407 ++++
.../hibernate/HibernateL2CacheMultiJvmTest.java | 429 ++++
.../hibernate/HibernateL2CacheSelfTest.java | 1960 ++++++++++++++++++
.../HibernateL2CacheTransactionalSelfTest.java | 154 ++
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 +
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 +
.../CacheHibernateBlobStoreSelfTest.java | 114 +
.../CacheHibernateStoreFactorySelfTest.java | 256 +++
...heHibernateStoreSessionListenerSelfTest.java | 242 +++
.../cache/store/hibernate/hibernate.cfg.xml | 42 +
.../cache/store/hibernate/package-info.java | 22 +
.../IgniteBinaryHibernate5TestSuite.java | 37 +
.../testsuites/IgniteHibernate5TestSuite.java | 57 +
modules/hibernate-core/pom.xml | 76 +
.../HibernateAccessStrategyAdapter.java | 340 +++
.../HibernateAccessStrategyFactory.java | 235 +++
.../cache/hibernate/HibernateCacheProxy.java | 801 +++++++
.../hibernate/HibernateExceptionConverter.java | 29 +
.../hibernate/HibernateKeyTransformer.java | 29 +
.../HibernateNonStrictAccessStrategy.java | 230 ++
.../HibernateReadOnlyAccessStrategy.java | 105 +
.../HibernateReadWriteAccessStrategy.java | 326 +++
.../HibernateTransactionalAccessStrategy.java | 141 ++
.../ignite/cache/hibernate/package-info.java | 24 +
modules/hibernate/README.txt | 48 -
modules/hibernate/licenses/apache-2.0.txt | 202 --
modules/hibernate/pom.xml | 146 --
.../HibernateAbstractRegionAccessStrategy.java | 98 -
.../HibernateAccessStrategyAdapter.java | 379 ----
.../cache/hibernate/HibernateCacheProxy.java | 801 -------
.../hibernate/HibernateCollectionRegion.java | 100 -
.../cache/hibernate/HibernateEntityRegion.java | 112 -
.../hibernate/HibernateGeneralDataRegion.java | 71 -
.../hibernate/HibernateKeyTransformer.java | 28 -
.../cache/hibernate/HibernateKeyWrapper.java | 72 -
.../hibernate/HibernateNaturalIdRegion.java | 100 -
.../HibernateNonStrictAccessStrategy.java | 222 --
.../hibernate/HibernateQueryResultsRegion.java | 70 -
.../HibernateReadOnlyAccessStrategy.java | 107 -
.../HibernateReadWriteAccessStrategy.java | 328 ---
.../ignite/cache/hibernate/HibernateRegion.java | 99 -
.../cache/hibernate/HibernateRegionFactory.java | 266 ---
.../hibernate/HibernateTimestampsRegion.java | 39 -
.../HibernateTransactionalAccessStrategy.java | 141 --
.../HibernateTransactionalDataRegion.java | 107 -
.../ignite/cache/hibernate/package-info.java | 24 -
.../hibernate/CacheHibernateBlobStore.java | 542 -----
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 -
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 -
.../CacheHibernateBlobStoreFactory.java | 235 ---
.../CacheHibernateStoreSessionListener.java | 222 --
.../cache/store/hibernate/package-info.java | 22 -
.../hibernate/src/test/config/factory-cache.xml | 59 -
.../src/test/config/factory-cache1.xml | 61 -
.../config/factory-incorrect-store-cache.xml | 56 -
.../HibernateL2CacheConfigurationSelfTest.java | 408 ----
.../hibernate/HibernateL2CacheSelfTest.java | 1949 -----------------
.../HibernateL2CacheTransactionalSelfTest.java | 154 --
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 -
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 -
.../CacheHibernateBlobStoreSelfTest.java | 113 -
.../CacheHibernateStoreFactorySelfTest.java | 285 ---
...heHibernateStoreSessionListenerSelfTest.java | 238 ---
.../cache/store/hibernate/hibernate.cfg.xml | 42 -
.../cache/store/hibernate/package-info.java | 22 -
.../IgniteBinaryHibernateTestSuite.java | 37 -
.../testsuites/IgniteHibernateTestSuite.java | 57 -
modules/hibernate5/README.txt | 48 -
modules/hibernate5/licenses/apache-2.0.txt | 202 --
modules/hibernate5/pom.xml | 146 --
.../HibernateAbstractRegionAccessStrategy.java | 99 -
.../HibernateAccessStrategyAdapter.java | 379 ----
.../cache/hibernate/HibernateCacheProxy.java | 801 -------
.../hibernate/HibernateCollectionRegion.java | 114 -
.../cache/hibernate/HibernateEntityRegion.java | 129 --
.../hibernate/HibernateGeneralDataRegion.java | 72 -
.../hibernate/HibernateKeyTransformer.java | 28 -
.../cache/hibernate/HibernateKeyWrapper.java | 108 -
.../hibernate/HibernateNaturalIdRegion.java | 113 -
.../HibernateNonStrictAccessStrategy.java | 222 --
.../hibernate/HibernateQueryResultsRegion.java | 70 -
.../HibernateReadOnlyAccessStrategy.java | 107 -
.../HibernateReadWriteAccessStrategy.java | 328 ---
.../ignite/cache/hibernate/HibernateRegion.java | 99 -
.../cache/hibernate/HibernateRegionFactory.java | 255 ---
.../hibernate/HibernateTimestampsRegion.java | 39 -
.../HibernateTransactionalAccessStrategy.java | 141 --
.../HibernateTransactionalDataRegion.java | 107 -
.../ignite/cache/hibernate/package-info.java | 24 -
.../hibernate/CacheHibernateBlobStore.java | 542 -----
.../CacheHibernateBlobStoreEntry.hbm.xml | 31 -
.../hibernate/CacheHibernateBlobStoreEntry.java | 89 -
.../CacheHibernateBlobStoreFactory.java | 235 ---
.../CacheHibernateStoreSessionListener.java | 223 --
.../cache/store/hibernate/package-info.java | 22 -
.../src/test/config/factory-cache.xml | 59 -
.../src/test/config/factory-cache1.xml | 61 -
.../config/factory-incorrect-store-cache.xml | 56 -
.../HibernateL2CacheConfigurationSelfTest.java | 409 ----
.../hibernate/HibernateL2CacheSelfTest.java | 1948 -----------------
.../HibernateL2CacheTransactionalSelfTest.java | 154 --
...nateL2CacheTransactionalUseSyncSelfTest.java | 31 -
.../CacheHibernateBlobStoreNodeRestartTest.java | 46 -
.../CacheHibernateBlobStoreSelfTest.java | 113 -
.../CacheHibernateStoreFactorySelfTest.java | 326 ---
...heHibernateStoreSessionListenerSelfTest.java | 241 ---
.../cache/store/hibernate/hibernate.cfg.xml | 42 -
.../cache/store/hibernate/package-info.java | 22 -
.../IgniteBinaryHibernate5TestSuite.java | 37 -
.../testsuites/IgniteHibernate5TestSuite.java | 57 -
.../osgi-karaf/src/main/resources/features.xml | 2 +-
pom.xml | 9 +-
178 files changed, 15647 insertions(+), 16667 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/assembly/dependencies-fabric.xml
----------------------------------------------------------------------
diff --git a/assembly/dependencies-fabric.xml b/assembly/dependencies-fabric.xml
index 23a1731..be68d0a 100644
--- a/assembly/dependencies-fabric.xml
+++ b/assembly/dependencies-fabric.xml
@@ -127,8 +127,9 @@
<exclude>org.apache.ignite:ignite-hadoop</exclude>
<exclude>org.apache.ignite:ignite-codegen</exclude>
<exclude>org.apache.ignite:ignite-apache-license-gen</exclude>
- <exclude>org.apache.ignite:ignite-hibernate</exclude>
- <exclude>org.apache.ignite:ignite-hibernate5</exclude>
+ <exclude>org.apache.ignite:ignite-hibernate-core</exclude>
+ <exclude>org.apache.ignite:ignite-hibernate_4.2</exclude>
+ <exclude>org.apache.ignite:ignite-hibernate_5.1</exclude>
<exclude>org.apache.ignite:ignite-schedule</exclude>
<exclude>org.apache.ignite:ignite-geospatial</exclude>
<exclude>org.apache.ignite:ignite-appserver-test</exclude>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/pom-standalone-lgpl.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone-lgpl.xml b/examples/pom-standalone-lgpl.xml
index 5fbb4ea..4798d03 100644
--- a/examples/pom-standalone-lgpl.xml
+++ b/examples/pom-standalone-lgpl.xml
@@ -191,7 +191,7 @@
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
+ <artifactId>ignite-hibernate_5.1</artifactId>
<version>to_be_replaced_by_ignite_version</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/pom-standalone.xml
----------------------------------------------------------------------
diff --git a/examples/pom-standalone.xml b/examples/pom-standalone.xml
index 0183563..e74082c 100644
--- a/examples/pom-standalone.xml
+++ b/examples/pom-standalone.xml
@@ -192,7 +192,7 @@
<dependencies>
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
+ <artifactId>ignite-hibernate_5.1</artifactId>
<version>to_be_replaced_by_ignite_version</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/pom.xml
----------------------------------------------------------------------
diff --git a/examples/pom.xml b/examples/pom.xml
index 895519b..26f653d 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -64,24 +64,6 @@
<dependency>
<groupId>org.apache.ignite</groupId>
- <artifactId>ignite-hibernate</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-schedule</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
- <artifactId>ignite-geospatial</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ignite</groupId>
<artifactId>ignite-spring-data</artifactId>
<version>${project.version}</version>
</dependency>
@@ -288,6 +270,26 @@
<lgpl.folder>src/main/java-lgpl</lgpl.folder>
<lgpl.test.folder>src/test/java-lgpl</lgpl.test.folder>
</properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate_5.1</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-schedule</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-geospatial</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</profile>
</profiles>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
----------------------------------------------------------------------
diff --git a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
index a31d394..28aa6ca 100644
--- a/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
+++ b/examples/src/main/java-lgpl/org/apache/ignite/examples/datagrid/hibernate/HibernateL2CacheExample.java
@@ -31,9 +31,9 @@ import org.apache.ignite.examples.ExamplesUtils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
+import org.hibernate.boot.MetadataSources;
+import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.cache.spi.access.AccessType;
-import org.hibernate.cfg.Configuration;
-import org.hibernate.service.ServiceRegistryBuilder;
import org.hibernate.stat.SecondLevelCacheStatistics;
import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
@@ -226,14 +226,14 @@ public class HibernateL2CacheExample {
* @return New Hibernate {@link SessionFactory}.
*/
private static SessionFactory createHibernateSessionFactory(URL hibernateCfg) {
- ServiceRegistryBuilder builder = new ServiceRegistryBuilder();
+ StandardServiceRegistryBuilder builder = new StandardServiceRegistryBuilder();
builder.applySetting("hibernate.connection.url", JDBC_URL);
builder.applySetting("hibernate.show_sql", true);
- return new Configuration()
- .configure(hibernateCfg)
- .buildSessionFactory(builder.buildServiceRegistry());
+ builder.configure(hibernateCfg);
+
+ return new MetadataSources(builder.build()).buildMetadata().buildSessionFactory();
}
/**
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/README.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/README.txt b/modules/hibernate-4.2/README.txt
new file mode 100644
index 0000000..096b9d7
--- /dev/null
+++ b/modules/hibernate-4.2/README.txt
@@ -0,0 +1,48 @@
+Apache Ignite Hibernate Module
+------------------------------
+
+Apache Ignite Hibernate module provides Hibernate second-level cache (L2 cache) implementation based
+on Apache Ignite In-Memory Data Grid.
+
+To enable Hibernate module when starting a standalone node, move 'optional/ignite-hibernate' folder to
+'libs' folder before running 'ignite.{sh|bat}' script. The content of the module folder will
+be added to classpath in this case.
+
+Importing Hibernate Module In Maven Project
+-------------------------------------------
+
+If you are using Maven to manage dependencies of your project, you can add Hibernate module
+dependency like this (replace '${ignite.version}' with actual Ignite version you are
+interested in):
+
+<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">
+ ...
+ <dependencies>
+ ...
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-hibernate_4.2</artifactId>
+ <version>${ignite.version}</version>
+ </dependency>
+ ...
+ </dependencies>
+ ...
+</project>
+
+
+LGPL dependencies
+-----------------
+
+Ignite includes the following optional LGPL dependencies:
+ - Hibernate L2 Cache Integration, http://hibernate.org/orm/
+ - JTS Topology Suite for Geospatial indexing, http://tsusiatsoftware.net/jts/main.html
+ - cron4j for cron-based task scheduling, http://www.sauronsoftware.it/projects/cron4j
+
+Apache binary releases cannot include LGPL dependencies. If you would like include
+optional LGPL dependencies into your release, you should download the source release
+from Ignite website and do the build with the following maven command:
+
+mvn clean package -DskipTests -Prelease,lgpl
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/licenses/apache-2.0.txt
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/licenses/apache-2.0.txt b/modules/hibernate-4.2/licenses/apache-2.0.txt
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/modules/hibernate-4.2/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/ee1b19d3/modules/hibernate-4.2/pom.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/pom.xml b/modules/hibernate-4.2/pom.xml
new file mode 100644
index 0000000..c597b21
--- /dev/null
+++ b/modules/hibernate-4.2/pom.xml
@@ -0,0 +1,159 @@
+<?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_4.2</artifactId>
+ <version>2.0.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>4.2.21.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>
+
+ <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>
+ </plugins>
+ </build>
+</project>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
new file mode 100644
index 0000000..8bf4e9b
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java
@@ -0,0 +1,102 @@
+/*
+ * 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.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.access.RegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of L2 cache access strategy delegating to {@link HibernateAccessStrategyAdapter}.
+ */
+public abstract class HibernateAbstractRegionAccessStrategy implements RegionAccessStrategy {
+ /** */
+ final HibernateAccessStrategyAdapter stgy;
+
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ HibernateAbstractRegionAccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ this.stgy = stgy;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(Object key, long txTs) throws CacheException {
+ return stgy.get(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(Object key, Object val, long txTs, Object ver) throws CacheException {
+ stgy.putFromLoad(key, val);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean putFromLoad(Object key, Object val, long txTs, Object ver, boolean minimalPutOverride)
+ throws CacheException {
+ stgy.putFromLoad(key, val, minimalPutOverride);
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public SoftLock lockItem(Object key, Object ver) throws CacheException {
+ stgy.lock(key);
+
+ return null;
+ }
+
+ /** {@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 unlockItem(Object key, SoftLock lock) throws CacheException {
+ stgy.unlock(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void remove(Object key) throws CacheException {
+ stgy.remove(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void removeAll() 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();
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
new file mode 100644
index 0000000..dae476c
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java
@@ -0,0 +1,100 @@
+/*
+ * 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.CacheDataDescription;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.CollectionRegionAccessStrategy;
+
+/**
+ * Implementation of {@link CollectionRegion}. This region is used to store collection data.
+ * <p>
+ * L2 cache for collection can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entities. -->
+ * <mapping class="com.example.Entity"/>
+ * <mapping class="com.example.ChildEntity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entities and collection. -->
+ * <collection-cache collection="com.example.Entity" usage="nonstrict-read-write"/>
+ * <collection-cache collection="com.example.ChildEntity" usage="nonstrict-read-write"/>
+ * <collection-cache collection="com.example.Entity.children" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache for collection can be enabled using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * public class Entity {
+ * ...
+ *
+ * @javax.persistence.OneToMany(cascade=CascadeType.ALL, fetch=FetchType.EAGER)
+ * @javax.persistence.JoinColumn(name="PARENT_ID")
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * public List<ChildEntity> getChildren() {...}
+ * }
+ * </pre>
+ * Note: the collection cache does not cache the state of the actual entities in the cache, it caches only identifier
+ * values. For this reason, the collection cache should always be used in conjunction with
+ * the second-level cache for those entities expected to be cached as part of a collection cache.
+ */
+public class HibernateCollectionRegion extends HibernateTransactionalDataRegion implements CollectionRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ * @param dataDesc Region data description.
+ */
+ HibernateCollectionRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * Collection region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
+ implements CollectionRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegion getRegion() {
+ return HibernateCollectionRegion.this;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
new file mode 100644
index 0000000..db921dc
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java
@@ -0,0 +1,112 @@
+/*
+ * 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.CacheDataDescription;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+
+/**
+ * Implementation of {@link EntityRegion}. This region is used to store entity data.
+ * <p>
+ * L2 cache for entity can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * Also cache for entity can be enabled using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * public class Entity { ... }
+ * </pre>
+ */
+public class HibernateEntityRegion extends HibernateTransactionalDataRegion implements EntityRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache,
+ * @param dataDesc Region data description.
+ */
+ HibernateEntityRegion(HibernateRegionFactory factory, String name, Ignite ignite,
+ HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * Entity region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy
+ implements EntityRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegion getRegion() {
+ return HibernateEntityRegion.this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val, Object ver) throws CacheException {
+ return stgy.insert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val, Object ver) throws CacheException {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val, Object currVer, Object previousVer)
+ throws CacheException {
+ return stgy.update(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val, Object currVer, Object previousVer, SoftLock lock)
+ throws CacheException {
+ return stgy.afterUpdate(key, val);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
new file mode 100644
index 0000000..578d88b
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java
@@ -0,0 +1,76 @@
+/*
+ * 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.GeneralDataRegion;
+import org.hibernate.cache.spi.QueryResultsRegion;
+import org.hibernate.cache.spi.TimestampsRegion;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Implementation of {@link GeneralDataRegion}. This interface defines common contract for {@link QueryResultsRegion}
+ * and {@link TimestampsRegion}.
+ */
+public class HibernateGeneralDataRegion extends HibernateRegion implements GeneralDataRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ HibernateGeneralDataRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+
+ /** {@inheritDoc} */
+ @Nullable @Override public Object get(Object key) throws CacheException {
+ try {
+ return cache.get(key);
+ } catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void put(Object key, Object val) throws CacheException {
+ try {
+ cache.put(key, val);
+ } catch (IgniteCheckedException e) {
+ throw new CacheException(e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evict(Object key) throws CacheException {
+ HibernateAccessStrategyAdapter.evict(ignite, cache, key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void evictAll() throws CacheException {
+ 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/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
new file mode 100644
index 0000000..64de395
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java
@@ -0,0 +1,73 @@
+/*
+ * 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;
+
+/**
+ * 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;
+ }
+
+ /** {@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/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
new file mode 100644
index 0000000..ae1099d
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java
@@ -0,0 +1,103 @@
+/*
+ * 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.CacheDataDescription;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.access.AccessType;
+import org.hibernate.cache.spi.access.NaturalIdRegionAccessStrategy;
+import org.hibernate.cache.spi.access.SoftLock;
+
+/**
+ * Implementation of {@link NaturalIdRegion}. This region is used to store naturalId data.
+ * <p>
+ * L2 cache for entity naturalId and target cache region can be set using annotations:
+ * <pre name="code" class="java">
+ * @javax.persistence.Entity
+ * @javax.persistence.Cacheable
+ * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
+ * @org.hibernate.annotations.NaturalIdCache
+ * public class Entity {
+ * @org.hibernate.annotations.NaturalId
+ * private String entityCode;
+ *
+ * ...
+ * }
+ * </pre>
+ */
+public class HibernateNaturalIdRegion extends HibernateTransactionalDataRegion implements NaturalIdRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache,
+ * @param dataDesc Region data description.
+ */
+ HibernateNaturalIdRegion(HibernateRegionFactory factory,
+ String name,
+ Ignite ignite,
+ HibernateCacheProxy cache,
+ CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache, dataDesc);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegionAccessStrategy buildAccessStrategy(AccessType accessType) throws CacheException {
+ return new AccessStrategy(createAccessStrategy(accessType));
+ }
+
+ /**
+ * NaturalId region access strategy.
+ */
+ private class AccessStrategy extends HibernateAbstractRegionAccessStrategy implements
+ NaturalIdRegionAccessStrategy {
+ /**
+ * @param stgy Access strategy implementation.
+ */
+ private AccessStrategy(HibernateAccessStrategyAdapter stgy) {
+ super(stgy);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegion getRegion() {
+ return HibernateNaturalIdRegion.this;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean insert(Object key, Object val) throws CacheException {
+ return stgy.insert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterInsert(Object key, Object val) throws CacheException {
+ return stgy.afterInsert(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean update(Object key, Object val) throws CacheException {
+ return stgy.update(key, val);
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean afterUpdate(Object key, Object val, SoftLock lock) throws CacheException {
+ return stgy.afterUpdate(key, val);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
new file mode 100644
index 0000000..fccbb5e
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java
@@ -0,0 +1,70 @@
+/*
+ * 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.Query;
+import org.hibernate.cache.spi.QueryResultsRegion;
+
+/**
+ * Implementation of {@link QueryResultsRegion}. This region is used to store query results.
+ * <p>
+ * Query results caching can be enabled in the Hibernate configuration file:
+ * <pre name="code" class="xml">
+ * <hibernate-configuration>
+ * <!-- Enable L2 cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+ *
+ * <!-- Enable query cache. -->
+ * <property name="cache.use_second_level_cache">true</property>
+
+ * <!-- Use Ignite as L2 cache provider. -->
+ * <property name="cache.region.factory_class">org.apache.ignite.cache.hibernate.HibernateRegionFactory</property>
+ *
+ * <!-- Specify entity. -->
+ * <mapping class="com.example.Entity"/>
+ *
+ * <!-- Enable L2 cache with nonstrict-read-write access strategy for entity. -->
+ * <class-cache class="com.example.Entity" usage="nonstrict-read-write"/>
+ * </hibernate-configuration>
+ * </pre>
+ * By default queries are not cached even after enabling query caching, to enable results caching for a particular
+ * query, call {@link Query#setCacheable(boolean)}:
+ * <pre name="code" class="java">
+ * Session ses = getSession();
+ *
+ * Query qry = ses.createQuery("...");
+ *
+ * qry.setCacheable(true); // Enable L2 cache for query.
+ * </pre>
+ * Note: the query cache does not cache the state of the actual entities in the cache, it caches only identifier
+ * 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
+ */
+class HibernateQueryResultsRegion extends HibernateGeneralDataRegion implements QueryResultsRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ HibernateQueryResultsRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
new file mode 100644
index 0000000..3666732
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java
@@ -0,0 +1,99 @@
+/*
+ * 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.Collections;
+import java.util.Map;
+import org.apache.ignite.Ignite;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.Region;
+
+/**
+ * Implementation of {@link Region}. This interface defines base contract for all L2 cache regions.
+ */
+public class HibernateRegion implements Region {
+ /** */
+ protected final HibernateRegionFactory factory;
+
+ /** */
+ private final String name;
+
+ /** Cache instance. */
+ protected final HibernateCacheProxy cache;
+
+ /** Grid instance. */
+ protected Ignite ignite;
+
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ HibernateRegion(HibernateRegionFactory factory, String name, Ignite ignite, HibernateCacheProxy cache) {
+ this.factory = factory;
+ this.name = name;
+ this.ignite = ignite;
+ this.cache = cache;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String getName() {
+ return name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void destroy() throws CacheException {
+ // No-op.
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean contains(Object key) {
+ return cache.containsKey(key);
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getSizeInMemory() {
+ return -1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountInMemory() {
+ return cache.size();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long getElementCountOnDisk() {
+ return -1;
+ }
+
+ /** {@inheritDoc} */
+ @Override public Map toMap() {
+ return Collections.emptyMap();
+ }
+
+ /** {@inheritDoc} */
+ @Override public long nextTimestamp() {
+ return System.currentTimeMillis();
+ }
+
+ /** {@inheritDoc} */
+ @Override public int getTimeout() {
+ return 0;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
new file mode 100644
index 0000000..5667eb2
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java
@@ -0,0 +1,179 @@
+/*
+ * 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.Properties;
+import org.apache.ignite.internal.processors.cache.IgniteInternalCache;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.spi.CacheDataDescription;
+import org.hibernate.cache.spi.CacheKey;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.NaturalIdRegion;
+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.cfg.Settings;
+
+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) {
+ if (key instanceof CacheKey) {
+ CacheKey cacheKey = (CacheKey)key;
+
+ return new HibernateKeyWrapper(
+ cacheKey.getKey(),
+ cacheKey.getEntityOrRoleName(),
+ cacheKey.getTenantId()
+ );
+ }
+
+ return key;
+ }
+ };
+
+ /** */
+ private final HibernateAccessStrategyFactory accessStgyFactory =
+ new HibernateAccessStrategyFactory(hibernate4transformer, EXCEPTION_CONVERTER);
+
+ /** {@inheritDoc} */
+ @Override public void start(Settings settings, Properties props) throws CacheException {
+ String accessType = props.getProperty(DFLT_ACCESS_TYPE_PROPERTY, NONSTRICT_READ_WRITE.name());
+
+ dfltAccessType = AccessType.valueOf(accessType);
+
+ accessStgyFactory.start(props);
+ }
+
+ /**
+ * @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 System.currentTimeMillis();
+ }
+
+ /** {@inheritDoc} */
+ @Override public EntityRegion buildEntityRegion(String regionName, Properties props, CacheDataDescription metadata)
+ throws CacheException {
+ return new HibernateEntityRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public NaturalIdRegion buildNaturalIdRegion(String regionName, Properties props,
+ CacheDataDescription metadata) throws CacheException {
+ return new HibernateNaturalIdRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public CollectionRegion buildCollectionRegion(String regionName, Properties props,
+ CacheDataDescription metadata) throws CacheException {
+ return new HibernateCollectionRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName),
+ metadata);
+ }
+
+ /** {@inheritDoc} */
+ @Override public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties props)
+ throws CacheException {
+ return new HibernateQueryResultsRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+
+ /** {@inheritDoc} */
+ @Override public TimestampsRegion buildTimestampsRegion(String regionName, Properties props) throws CacheException {
+ return new HibernateTimestampsRegion(this,
+ regionName,
+ accessStgyFactory.node(),
+ accessStgyFactory.regionCache(regionName));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
new file mode 100644
index 0000000..8b4c243
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java
@@ -0,0 +1,39 @@
+/*
+ * 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.TimestampsRegion;
+
+/**
+ * Implementation of {@link TimestampsRegion}. This region is automatically created when query
+ * caching is enabled and it holds most recent updates timestamps to queryable tables.
+ * Name of timestamps region is {@code "org.hibernate.cache.spi.UpdateTimestampsCache"}.
+ */
+public class HibernateTimestampsRegion extends HibernateGeneralDataRegion implements TimestampsRegion {
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ */
+ public HibernateTimestampsRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache) {
+ super(factory, name, ignite, cache);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
new file mode 100644
index 0000000..275ea9e
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
@@ -0,0 +1,84 @@
+/*
+ * 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.CacheDataDescription;
+import org.hibernate.cache.spi.CollectionRegion;
+import org.hibernate.cache.spi.EntityRegion;
+import org.hibernate.cache.spi.NaturalIdRegion;
+import org.hibernate.cache.spi.TransactionalDataRegion;
+import org.hibernate.cache.spi.access.AccessType;
+
+/**
+ * Implementation of {@link TransactionalDataRegion} (transactional means that
+ * data in the region is updated in connection with database transaction).
+ * This interface defines base contract for {@link EntityRegion}, {@link CollectionRegion}
+ * and {@link NaturalIdRegion}.
+ */
+public class HibernateTransactionalDataRegion extends HibernateRegion implements TransactionalDataRegion {
+ /** */
+ private final CacheDataDescription dataDesc;
+
+ /**
+ * @param factory Region factory.
+ * @param name Region name.
+ * @param ignite Grid.
+ * @param cache Region cache.
+ * @param dataDesc Region data description.
+ */
+ HibernateTransactionalDataRegion(HibernateRegionFactory factory, String name,
+ Ignite ignite, HibernateCacheProxy cache, CacheDataDescription dataDesc) {
+ super(factory, name, ignite, cache);
+
+ this.dataDesc = dataDesc;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean isTransactionAware() {
+ return false; // This method is not used by Hibernate.
+ }
+
+ /** {@inheritDoc} */
+ @Override public CacheDataDescription getCacheDataDescription() {
+ return dataDesc;
+ }
+
+ /**
+ * @param accessType Hibernate L2 cache access type.
+ * @return Access strategy for given access type.
+ */
+ HibernateAccessStrategyAdapter createAccessStrategy(AccessType accessType) {
+ switch (accessType) {
+ case READ_ONLY:
+ return factory.accessStrategyFactory().createReadOnlyStrategy(cache);
+
+ case NONSTRICT_READ_WRITE:
+ return factory.accessStrategyFactory().createNonStrictReadWriteStrategy(cache);
+
+ case READ_WRITE:
+ return factory.accessStrategyFactory().createReadWriteStrategy(cache);
+
+ case TRANSACTIONAL:
+ return factory.accessStrategyFactory().createTransactionalStrategy(cache);
+
+ default:
+ throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee1b19d3/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
----------------------------------------------------------------------
diff --git a/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
new file mode 100644
index 0000000..1179aec
--- /dev/null
+++ b/modules/hibernate-4.2/src/main/java/org/apache/ignite/cache/hibernate/package-info.java
@@ -0,0 +1,24 @@
+/*
+ * 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 description. -->
+ * Contains implementation of Hibernate L2 cache. Refer to
+ * <i>org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample</i> for more information on how to
+ * configure and use Ignite with Hibernate.
+ */
+package org.apache.ignite.cache.hibernate;
\ No newline at end of file