Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id CDB13200C5C for ; Thu, 20 Apr 2017 11:35:55 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C96DA160BB0; Thu, 20 Apr 2017 09:35:55 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6FA85160B91 for ; Thu, 20 Apr 2017 11:35:53 +0200 (CEST) Received: (qmail 42321 invoked by uid 500); 20 Apr 2017 09:35:52 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 42241 invoked by uid 99); 20 Apr 2017 09:35:52 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Apr 2017 09:35:52 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6C636E0885; Thu, 20 Apr 2017 09:35:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sboikov@apache.org To: commits@ignite.apache.org Date: Thu, 20 Apr 2017 09:35:55 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [4/7] ignite git commit: ignite-1794 archived-at: Thu, 20 Apr 2017 09:35:56 -0000 http://git-wip-us.apache.org/repos/asf/ignite/blob/d992b949/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java new file mode 100644 index 0000000..880d12a --- /dev/null +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateStoreSessionListenerSelfTest.java @@ -0,0 +1,238 @@ +/* + * 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.store.hibernate; + +import java.io.Serializable; +import java.util.Map; +import javax.cache.Cache; +import javax.cache.configuration.Factory; +import javax.cache.integration.CacheLoaderException; +import javax.cache.integration.CacheWriterException; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; +import javax.persistence.Table; +import org.apache.ignite.cache.store.CacheStore; +import org.apache.ignite.cache.store.CacheStoreAdapter; +import org.apache.ignite.cache.store.CacheStoreSession; +import org.apache.ignite.cache.store.CacheStoreSessionListener; +import org.apache.ignite.cache.store.CacheStoreSessionListenerAbstractSelfTest; +import org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener; +import org.apache.ignite.lang.IgniteBiInClosure; +import org.apache.ignite.resources.CacheStoreSessionResource; +import org.hibernate.Session; +import org.hibernate.SessionFactory; +import org.hibernate.Transaction; +import org.hibernate.cfg.Configuration; + +/** + * Tests for {@link CacheJdbcStoreSessionListener}. + */ +public class CacheHibernateStoreSessionListenerSelfTest extends CacheStoreSessionListenerAbstractSelfTest { + /** {@inheritDoc} */ + @Override protected Factory> storeFactory() { + return new Factory>() { + @Override public CacheStore create() { + return new Store(); + } + }; + } + + /** {@inheritDoc} */ + @Override protected Factory sessionListenerFactory() { + return new Factory() { + @Override public CacheStoreSessionListener create() { + CacheHibernateStoreSessionListener lsnr = new CacheHibernateStoreSessionListener(); + + SessionFactory sesFactory = new Configuration(). + setProperty("hibernate.connection.url", URL). + addAnnotatedClass(Table1.class). + addAnnotatedClass(Table2.class). + buildSessionFactory(); + + lsnr.setSessionFactory(sesFactory); + + return lsnr; + } + }; + } + + /** + */ + private static class Store extends CacheStoreAdapter { + /** */ + private static String SES_CONN_KEY = "ses_conn"; + + /** */ + @CacheStoreSessionResource + private CacheStoreSession ses; + + /** {@inheritDoc} */ + @Override public void loadCache(IgniteBiInClosure clo, Object... args) { + loadCacheCnt.incrementAndGet(); + + checkSession(); + } + + /** {@inheritDoc} */ + @Override public Integer load(Integer key) throws CacheLoaderException { + loadCnt.incrementAndGet(); + + checkSession(); + + return null; + } + + /** {@inheritDoc} */ + @Override public void write(Cache.Entry entry) + throws CacheWriterException { + writeCnt.incrementAndGet(); + + checkSession(); + + if (write.get()) { + Session hibSes = ses.attachment(); + + switch (ses.cacheName()) { + case "cache1": + hibSes.save(new Table1(entry.getKey(), entry.getValue())); + + break; + + case "cache2": + if (fail.get()) + throw new CacheWriterException("Expected failure."); + + hibSes.save(new Table2(entry.getKey(), entry.getValue())); + + break; + + default: + throw new CacheWriterException("Wring cache: " + ses.cacheName()); + } + } + } + + /** {@inheritDoc} */ + @Override public void delete(Object key) throws CacheWriterException { + deleteCnt.incrementAndGet(); + + checkSession(); + } + + /** {@inheritDoc} */ + @Override public void sessionEnd(boolean commit) { + assertNull(ses.attachment()); + } + + /** + */ + private void checkSession() { + Session hibSes = ses.attachment(); + + assertNotNull(hibSes); + + assertTrue(hibSes.isOpen()); + + Transaction tx = hibSes.getTransaction(); + + assertNotNull(tx); + + if (ses.isWithinTransaction()) + assertTrue(tx.isActive()); + else + assertFalse(tx.isActive()); + + verifySameInstance(hibSes); + } + + /** + * @param hibSes Session. + */ + private void verifySameInstance(Session hibSes) { + Map props = ses.properties(); + + Session sesConn = props.get(SES_CONN_KEY); + + if (sesConn == null) + props.put(SES_CONN_KEY, hibSes); + else { + assertSame(hibSes, sesConn); + + reuseCnt.incrementAndGet(); + } + } + } + + /** + */ + @Entity + @Table(name = "Table1") + private static class Table1 implements Serializable { + /** */ + @Id @GeneratedValue + @Column(name = "id") + private Integer id; + + /** */ + @Column(name = "key") + private int key; + + /** */ + @Column(name = "value") + private int value; + + /** + * @param key Key. + * @param value Value. + */ + private Table1(int key, int value) { + this.key = key; + this.value = value; + } + } + + /** + */ + @Entity + @Table(name = "Table2") + private static class Table2 implements Serializable { + /** */ + @Id @GeneratedValue + @Column(name = "id") + private Integer id; + + /** */ + @Column(name = "key") + private int key; + + /** */ + @Column(name = "value") + private int value; + + /** + * @param key Key. + * @param value Value. + */ + private Table2(int key, int value) { + this.key = key; + this.value = value; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/d992b949/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml ---------------------------------------------------------------------- diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml new file mode 100644 index 0000000..3822b31 --- /dev/null +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + true + + + jdbc:h2:mem:example;DB_CLOSE_DELAY=-1 + + + update + + + org.hibernate.dialect.H2Dialect + + + + + http://git-wip-us.apache.org/repos/asf/ignite/blob/d992b949/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java new file mode 100644 index 0000000..8af9886 --- /dev/null +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/cache/store/hibernate/package-info.java @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/** + * + * Contains internal tests or test related classes and interfaces. + */ +package org.apache.ignite.cache.store.hibernate; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/d992b949/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java new file mode 100644 index 0000000..3791bae --- /dev/null +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteBinaryHibernateTestSuite.java @@ -0,0 +1,37 @@ +/* + * 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.testsuites; + +import junit.framework.TestSuite; +import org.apache.ignite.internal.binary.BinaryMarshaller; +import org.apache.ignite.testframework.config.GridTestProperties; + +/** + * + */ +public class IgniteBinaryHibernateTestSuite extends TestSuite { + /** + * @return Test suite. + * @throws Exception If failed. + */ + public static TestSuite suite() throws Exception { + GridTestProperties.setProperty(GridTestProperties.MARSH_CLASS_NAME, BinaryMarshaller.class.getName()); + + return IgniteHibernateTestSuite.suite(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d992b949/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java ---------------------------------------------------------------------- diff --git a/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java new file mode 100644 index 0000000..99fea56 --- /dev/null +++ b/modules/hibernate-4.2/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java @@ -0,0 +1,57 @@ +/* + * 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.testsuites; + +import junit.framework.TestSuite; +import org.apache.ignite.cache.hibernate.HibernateL2CacheConfigurationSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalSelfTest; +import org.apache.ignite.cache.hibernate.HibernateL2CacheTransactionalUseSyncSelfTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreNodeRestartTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreSelfTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreFactorySelfTest; +import org.apache.ignite.cache.store.hibernate.CacheHibernateStoreSessionListenerSelfTest; + +/** + * Hibernate integration tests. + */ +public class IgniteHibernateTestSuite extends TestSuite { + /** + * @return Test suite. + * @throws Exception Thrown in case of the failure. + */ + public static TestSuite suite() throws Exception { + TestSuite suite = new TestSuite("Hibernate Integration Test Suite"); + + // Hibernate L2 cache. + suite.addTestSuite(HibernateL2CacheSelfTest.class); + suite.addTestSuite(HibernateL2CacheTransactionalSelfTest.class); + suite.addTestSuite(HibernateL2CacheTransactionalUseSyncSelfTest.class); + suite.addTestSuite(HibernateL2CacheConfigurationSelfTest.class); + + suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class); + + suite.addTestSuite(CacheHibernateBlobStoreNodeRestartTest.class); + + suite.addTestSuite(CacheHibernateStoreSessionListenerSelfTest.class); + + suite.addTestSuite(CacheHibernateStoreFactorySelfTest.class); + + return suite; + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/d992b949/modules/hibernate/README.txt ---------------------------------------------------------------------- diff --git a/modules/hibernate/README.txt b/modules/hibernate/README.txt deleted file mode 100644 index 8e90dab..0000000 --- a/modules/hibernate/README.txt +++ /dev/null @@ -1,48 +0,0 @@ -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): - - - ... - - ... - - org.apache.ignite - ignite-hibernate - ${ignite.version} - - ... - - ... - - - -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/d992b949/modules/hibernate/licenses/apache-2.0.txt ---------------------------------------------------------------------- diff --git a/modules/hibernate/licenses/apache-2.0.txt b/modules/hibernate/licenses/apache-2.0.txt deleted file mode 100644 index d645695..0000000 --- a/modules/hibernate/licenses/apache-2.0.txt +++ /dev/null @@ -1,202 +0,0 @@ - - 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/d992b949/modules/hibernate/pom.xml ---------------------------------------------------------------------- diff --git a/modules/hibernate/pom.xml b/modules/hibernate/pom.xml deleted file mode 100644 index c4586b3..0000000 --- a/modules/hibernate/pom.xml +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - 4.0.0 - - - org.apache.ignite - ignite-parent - 1 - ../../parent - - - ignite-hibernate - 2.0.0-SNAPSHOT - http://ignite.apache.org - - - - org.apache.ignite - ignite-core - ${project.version} - - - - org.apache.ignite - ignite-hibernate-core - ${project.version} - - - - org.hibernate - hibernate-core - 4.2.6.Final - - - - org.apache.ignite - ignite-jta - ${project.version} - test - - - - org.ow2.jotm - jotm-core - 2.1.9 - test - - - - commons-dbcp - commons-dbcp - 1.4 - test - - - - com.h2database - h2 - ${h2.version} - test - - - - javax.resource - connector-api - 1.5 - test - - - - org.apache.ignite - ignite-core - ${project.version} - test-jar - test - - - - org.apache.ignite - ignite-spring - ${project.version} - test - - - - org.apache.ignite - ignite-log4j - ${project.version} - test - - - - org.springframework - spring-beans - ${spring.version} - test - - - - org.springframework - spring-context - ${spring.version} - test - - - - - - - src/main/java - - **/*.java - - - - src/test/java - - **/*.java - - - - - - - - org.apache.felix - maven-bundle-plugin - - - - http://git-wip-us.apache.org/repos/asf/ignite/blob/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java deleted file mode 100644 index 8bf4e9b..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateAbstractRegionAccessStrategy.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java deleted file mode 100644 index dae476c..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateCollectionRegion.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.apache.ignite.Ignite; -import org.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. - *

- * L2 cache for collection can be enabled in the Hibernate configuration file: - *

- * <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>
- * 
- * Also cache for collection can be enabled using annotations: - *
- * @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() {...}
- * }
- * 
- * 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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java deleted file mode 100644 index db921dc..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateEntityRegion.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.apache.ignite.Ignite; -import org.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. - *

- * L2 cache for entity can be enabled in the Hibernate configuration file: - *

- * <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>
- * 
- * Also cache for entity can be enabled using annotations: - *
- * @javax.persistence.Entity
- * @javax.persistence.Cacheable
- * @org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
- * public class Entity { ... }
- * 
- */ -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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java deleted file mode 100644 index 578d88b..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateGeneralDataRegion.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.apache.ignite.Ignite; -import org.apache.ignite.IgniteCheckedException; -import org.hibernate.cache.CacheException; -import org.hibernate.cache.spi.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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java deleted file mode 100644 index 64de395..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateKeyWrapper.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import java.io.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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java deleted file mode 100644 index ae1099d..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateNaturalIdRegion.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.apache.ignite.Ignite; -import org.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. - *

- * L2 cache for entity naturalId and target cache region can be set using annotations: - *

- * @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;
- *
- *     ...
- * }
- * 
- */ -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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java deleted file mode 100644 index fccbb5e..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateQueryResultsRegion.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.apache.ignite.Ignite; -import org.hibernate.Query; -import org.hibernate.cache.spi.QueryResultsRegion; - -/** - * Implementation of {@link QueryResultsRegion}. This region is used to store query results. - *

- * Query results caching can be enabled in the Hibernate configuration file: - *

- * <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>
- * 
- * By default queries are not cached even after enabling query caching, to enable results caching for a particular - * query, call {@link Query#setCacheable(boolean)}: - *
- *     Session ses = getSession();
- *
- *     Query qry = ses.createQuery("...");
- *
- *     qry.setCacheable(true); // Enable L2 cache for query.
- * 
- * 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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java deleted file mode 100644 index 3666732..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegion.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import java.util.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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java deleted file mode 100644 index 5667eb2..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateRegionFactory.java +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import java.util.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. - *

- * Following Hibernate settings should be specified to enable second level cache and to use this - * region factory for caching: - *

- * hibernate.cache.use_second_level_cache=true
- * hibernate.cache.region.factory_class=org.apache.ignite.cache.hibernate.HibernateRegionFactory
- * 
- * 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. - *

- * Name of Ignite instance to be used for region factory must be specified as following Hibernate property: - *

- * org.apache.ignite.hibernate.ignite_instance_name=<Ignite instance name>
- * 
- * 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: - *
- * org.apache.ignite.hibernate.region_cache.region1=cache1
- * 
- */ -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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java deleted file mode 100644 index 8b4c243..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTimestampsRegion.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.apache.ignite.Ignite; -import org.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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java deleted file mode 100644 index 275ea9e..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.cache.hibernate; - -import org.apache.ignite.Ignite; -import org.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/d992b949/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java ---------------------------------------------------------------------- diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java deleted file mode 100644 index 1179aec..0000000 --- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/package-info.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * - * Contains implementation of Hibernate L2 cache. Refer to - * org.apache.ignite.examples.datagrid.hibernate.HibernateL2CacheExample for more information on how to - * configure and use Ignite with Hibernate. - */ -package org.apache.ignite.cache.hibernate; \ No newline at end of file