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 2021/01/28 20:03:26 UTC
[isis] branch master updated: ISIS-2502: trying to turn on Spring's
exception translation for JPA
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 45d3a32 ISIS-2502: trying to turn on Spring's exception translation for JPA
45d3a32 is described below
commit 45d3a32ddd50094d84df585008ab7caf0da42aa7
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Jan 28 21:03:08 2021 +0100
ISIS-2502: trying to turn on Spring's exception translation for JPA
but no luck yet, helloworld(jpa) does not get JPA exceptions translated
exception translation for JDO however works
---
.../appfeat/ApplicationFeatureRepositoryDefault.java | 4 ++--
.../jpa/eclipselink/IsisModuleJpaEclipselink.java | 13 +++++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefault.java
index d508c97..c0cb69a 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/appfeat/ApplicationFeatureRepositoryDefault.java
@@ -30,7 +30,7 @@ import javax.inject.Inject;
import javax.inject.Named;
import org.springframework.context.event.EventListener;
-import org.springframework.stereotype.Repository;
+import org.springframework.stereotype.Service;
import org.apache.isis.applib.annotation.SemanticsOf;
import org.apache.isis.applib.annotation.Where;
@@ -59,7 +59,7 @@ import static org.apache.isis.commons.internal.base._NullSafe.stream;
import lombok.val;
import lombok.extern.log4j.Log4j2;
-@Repository
+@Service
@Named("isis.metamodel.ApplicationFeatureRepositoryDefault")
@Log4j2
public class ApplicationFeatureRepositoryDefault implements ApplicationFeatureRepository {
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
index 0d5e3c6..1e8c657 100644
--- 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
@@ -29,9 +29,12 @@ 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.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
+import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
+import org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect;
import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
import org.springframework.transaction.jta.JtaTransactionManager;
@@ -61,6 +64,16 @@ public class IsisModuleJpaEclipselink extends JpaBaseConfiguration {
@Inject private Provider<ServiceInjector> serviceInjectorProvider;
+ @Bean
+ public EclipseLinkJpaDialect eclipselinkJpaDialect() {
+ return new EclipseLinkJpaDialect();
+ }
+
+ @Bean
+ public PersistenceExceptionTranslationPostProcessor persistenceExceptionTranslationPostProcessor(){
+ return new PersistenceExceptionTranslationPostProcessor();
+ }
+
protected IsisModuleJpaEclipselink(
IsisConfiguration isisConfiguration,
DataSource dataSource,