You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2020/12/17 05:06:44 UTC
[isis] branch master updated: ISIS-2294: use eclipse link as JPA
persistence provider
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/master by this push:
new c476cff ISIS-2294: use eclipse link as JPA persistence provider
c476cff is described below
commit c476cff02fcae436ba5f78492c5b70239e149626
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Dec 17 06:06:32 2020 +0100
ISIS-2294: use eclipse link as JPA persistence provider
---
core/pom.xml | 5 ++
persistence/jpa/eclipselink/pom.xml | 34 +++++++++--
.../jpa/eclipselink/IsisModuleJpaEclipseLink.java | 71 ++++++++++++++++++++++
persistence/jpa/pom.xml | 1 +
regressiontests/pom.xml | 5 ++
.../testdomain/conf/Configuration_usingJpa.java | 4 +-
6 files changed, 112 insertions(+), 8 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index 1aad311..7bf4a8e 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -767,6 +767,11 @@
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.apache.isis.persistence</groupId>
+ <artifactId>isis-persistence-jpa-eclipselink</artifactId>
+ <version>2.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-restfulobjects-jaxrsresteasy4</artifactId>
<version>2.0.0-SNAPSHOT</version>
diff --git a/persistence/jpa/eclipselink/pom.xml b/persistence/jpa/eclipselink/pom.xml
index 29c53d1..238e626 100644
--- a/persistence/jpa/eclipselink/pom.xml
+++ b/persistence/jpa/eclipselink/pom.xml
@@ -70,17 +70,39 @@
<dependency>
<groupId>org.apache.isis.persistence</groupId>
- <artifactId>isis-persistence-jpa-applib</artifactId>
+ <artifactId>isis-persistence-jpa-model</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.isis.core</groupId>
- <artifactId>isis-core-runtime</artifactId>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.jpa</artifactId>
+ <version>2.7.7</version>
</dependency>
-
+
<dependency>
- <groupId>org.springframework.data</groupId>
- <artifactId>spring-data-jpa</artifactId>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-data-jpa</artifactId>
+ <exclusions>
+ <exclusion>
+ <!-- using eclipse-link instead -->
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-entitymanager</artifactId>
+ </exclusion>
+ <exclusion>
+ <!-- using eclipse-link instead -->
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>javax.validation</groupId>
+ <artifactId>validation-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <!-- we use log4j-2 instead -->
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- TESTING -->
diff --git a/persistence/jpa/eclipselink/src/main/java/org/apache/isis/persistence/jpa/eclipselink/IsisModuleJpaEclipseLink.java b/persistence/jpa/eclipselink/src/main/java/org/apache/isis/persistence/jpa/eclipselink/IsisModuleJpaEclipseLink.java
new file mode 100644
index 0000000..cfa5e47
--- /dev/null
+++ b/persistence/jpa/eclipselink/src/main/java/org/apache/isis/persistence/jpa/eclipselink/IsisModuleJpaEclipseLink.java
@@ -0,0 +1,71 @@
+/*
+ * 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.isis.persistence.jpa.eclipselink;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.sql.DataSource;
+
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
+import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
+import org.springframework.transaction.jta.JtaTransactionManager;
+
+import org.apache.isis.persistence.jpa.IsisModuleJpa;
+
+/**
+ * EclipseLink integration.
+ * Sets up EclipseLink as the implementation provider for Spring Data JPA.
+ *
+ * @see <a href=https://www.baeldung.com/spring-eclipselink>baeldung.com</a>
+ */
+@Configuration
+@Import({
+ IsisModuleJpa.class
+})
+public class IsisModuleJpaEclipseLink extends JpaBaseConfiguration {
+
+ protected IsisModuleJpaEclipseLink(
+ DataSource dataSource,
+ JpaProperties properties,
+ ObjectProvider<JtaTransactionManager> jtaTransactionManager) {
+ super(dataSource, properties, jtaTransactionManager);
+ }
+
+ @Override
+ protected AbstractJpaVendorAdapter createJpaVendorAdapter() {
+ return new EclipseLinkJpaVendorAdapter();
+ }
+
+ //TODO[2033] this is application specific configuration that belongs to application.yaml
+ @Override
+ protected Map<String, Object> getVendorProperties() {
+ HashMap<String, Object> map = new HashMap<>();
+ map.put(PersistenceUnitProperties.WEAVING, "false");
+ map.put(PersistenceUnitProperties.DDL_GENERATION, PersistenceUnitProperties.DROP_AND_CREATE);
+ return map;
+ }
+
+}
\ No newline at end of file
diff --git a/persistence/jpa/pom.xml b/persistence/jpa/pom.xml
index 549d244..0b2ae78 100644
--- a/persistence/jpa/pom.xml
+++ b/persistence/jpa/pom.xml
@@ -33,6 +33,7 @@
<modules>
<module>applib</module>
<module>model</module>
+ <module>eclipselink</module>
</modules>
diff --git a/regressiontests/pom.xml b/regressiontests/pom.xml
index 8ced39f..3fa95e9 100644
--- a/regressiontests/pom.xml
+++ b/regressiontests/pom.xml
@@ -350,6 +350,11 @@
<groupId>org.apache.isis.viewer</groupId>
<artifactId>isis-viewer-common</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.isis.persistence</groupId>
+ <artifactId>isis-persistence-jpa-eclipselink</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.isis.testing</groupId>
diff --git a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJpa.java b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJpa.java
index 218bf45..79388f8 100644
--- a/regressiontests/stable/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJpa.java
+++ b/regressiontests/stable/src/main/java/org/apache/isis/testdomain/conf/Configuration_usingJpa.java
@@ -28,7 +28,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.apache.isis.core.config.presets.IsisPresets;
import org.apache.isis.core.runtimeservices.IsisModuleCoreRuntimeServices;
-import org.apache.isis.persistence.jpa.IsisModuleJpa;
+import org.apache.isis.persistence.jpa.eclipselink.IsisModuleJpaEclipseLink;
import org.apache.isis.security.bypass.IsisModuleSecurityBypass;
import org.apache.isis.testdomain.jpa.JpaTestDomainModule;
import org.apache.isis.testdomain.util.kv.KVStoreForTesting;
@@ -41,7 +41,7 @@ import org.apache.isis.testdomain.util.kv.KVStoreForTesting;
@Import({
IsisModuleCoreRuntimeServices.class
,IsisModuleSecurityBypass.class
- ,IsisModuleJpa.class,
+ ,IsisModuleJpaEclipseLink.class,
//,IsisModuleTestingFixturesApplib.class
KVStoreForTesting.class, // Helper for JUnit Tests
})