From 8cd7521c2f332e024ead1b503305414db707c68f Mon Sep 17 00:00:00 2001 From: hanshuai03 <14693422+hanshuai03@user.noreply.gitee.com> Date: Tue, 16 Dec 2025 17:30:16 +0800 Subject: [PATCH 1/4] =?UTF-8?q?jpa=E4=B8=BB=E5=BA=93=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=8C=96=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- caf-data/caf-data-jpa/pom.xml | 8 +++++++ .../Impl/DBTransactionServiceImpl.java | 23 +++++++++++++++++-- ...EcpDBTransactionWarningRpcPersistence.java | 11 +++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java diff --git a/caf-data/caf-data-jpa/pom.xml b/caf-data/caf-data-jpa/pom.xml index a5b627f9e..6d8647bb1 100644 --- a/caf-data/caf-data-jpa/pom.xml +++ b/caf-data/caf-data-jpa/pom.xml @@ -43,6 +43,14 @@ io.iec.edp caf-data-jdbc + + io.iec.edp + caf-rpc-api + + + io.iec.edp + caf-rpc-client + org.projectlombok diff --git a/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java b/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java index 573209dda..acac8c928 100644 --- a/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java +++ b/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java @@ -16,12 +16,15 @@ package io.iec.edp.caf.commons.transaction.Impl; +import io.iec.edp.caf.commons.runtime.CafEnvironment; import io.iec.edp.caf.commons.transaction.JpaTransaction; import io.iec.edp.caf.commons.transaction.TransactionPropagation; import io.iec.edp.caf.commons.transaction.entity.EcpDBTransactionWarning; +import io.iec.edp.caf.commons.transaction.persistence.EcpDBTransactionWarningRpcPersistence; import io.iec.edp.caf.commons.transaction.repository.EcpDBTransactionWarningRepository; import io.iec.edp.caf.commons.transaction.service.DBTransactionService; import io.iec.edp.caf.datasource.CAFDataSourceSelector; +import io.iec.edp.caf.rpc.client.RpcClassHolder; import lombok.extern.slf4j.Slf4j; import java.time.OffsetDateTime; @@ -37,9 +40,14 @@ public class DBTransactionServiceImpl implements DBTransactionService { //持久层 private EcpDBTransactionWarningRepository repo; + private EcpDBTransactionWarningRpcPersistence dbTransactionWarningRpcPersistence; + + private final RpcClassHolder rpcClassHolder; + //构造注入 - public DBTransactionServiceImpl(EcpDBTransactionWarningRepository repo) { + public DBTransactionServiceImpl(EcpDBTransactionWarningRepository repo, RpcClassHolder rpcClassHolder) { this.repo = repo; + this.rpcClassHolder = rpcClassHolder; } @Override @@ -54,7 +62,11 @@ public class DBTransactionServiceImpl implements DBTransactionService { JpaTransaction transaction = JpaTransaction.getTransaction(); try { transaction.begin(TransactionPropagation.REQUIRES_NEW); - repo.save(entity); + if (CafEnvironment.enablePrimaryDataService()) { + getDbTransactionWarningRpcPersistence().save(entity); + } else { + repo.save(entity); + } transaction.commit(); } catch (Throwable e) { transaction.rollback(); @@ -66,4 +78,11 @@ public class DBTransactionServiceImpl implements DBTransactionService { } } } + + private EcpDBTransactionWarningRpcPersistence getDbTransactionWarningRpcPersistence(){ + if(this.dbTransactionWarningRpcPersistence==null){ + this.dbTransactionWarningRpcPersistence = rpcClassHolder.getRpcClass("sys", EcpDBTransactionWarningRpcPersistence.class); + } + return this.dbTransactionWarningRpcPersistence; + } } diff --git a/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java b/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java new file mode 100644 index 000000000..f2943c781 --- /dev/null +++ b/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java @@ -0,0 +1,11 @@ +package io.iec.edp.caf.commons.transaction.persistence; + +import io.iec.edp.caf.commons.transaction.entity.EcpDBTransactionWarning; +import io.iec.edp.caf.rpc.api.annotation.GspServiceBundle; +import io.iec.edp.caf.rpc.api.annotation.RpcParam; + +@GspServiceBundle(applicationName = "runtime", serviceUnitName= "sys") +public interface EcpDBTransactionWarningRpcPersistence { + + void save(@RpcParam(paramName = "entity") EcpDBTransactionWarning entity); +} -- Gitee From 94ccc749e5b0d80d2b35418626f60b6ba794840c Mon Sep 17 00:00:00 2001 From: hanshuai03 <14693422+hanshuai03@user.noreply.gitee.com> Date: Tue, 13 Jan 2026 11:35:02 +0800 Subject: [PATCH 2/4] =?UTF-8?q?jpa=E4=B8=BB=E5=BA=93=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=8C=96=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- caf-data/caf-data-jpa/pom.xml | 8 ----- caf-extension/caf-data-jpa-extension/pom.xml | 34 +++++++++++++++++++ .../Impl/DBTransactionServiceImpl.java | 0 ...EcpDBTransactionWarningRpcPersistence.java | 0 4 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 caf-extension/caf-data-jpa-extension/pom.xml rename {caf-data/caf-data-jpa => caf-extension/caf-data-jpa-extension}/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java (100%) rename {caf-data/caf-data-jpa => caf-extension/caf-data-jpa-extension}/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java (100%) diff --git a/caf-data/caf-data-jpa/pom.xml b/caf-data/caf-data-jpa/pom.xml index 6d8647bb1..a5b627f9e 100644 --- a/caf-data/caf-data-jpa/pom.xml +++ b/caf-data/caf-data-jpa/pom.xml @@ -43,14 +43,6 @@ io.iec.edp caf-data-jdbc - - io.iec.edp - caf-rpc-api - - - io.iec.edp - caf-rpc-client - org.projectlombok diff --git a/caf-extension/caf-data-jpa-extension/pom.xml b/caf-extension/caf-data-jpa-extension/pom.xml new file mode 100644 index 000000000..b36acf4d7 --- /dev/null +++ b/caf-extension/caf-data-jpa-extension/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + io.iec.edp + caf-framework + 1.9.5-SNAPSHOT + + + caf-data-jpa-extension + + + 8 + 8 + UTF-8 + + + + + io.iec.edp + caf-data-jpa + + + io.iec.edp + caf-rpc-api + + + io.iec.edp + caf-rpc-client + + + \ No newline at end of file diff --git a/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java b/caf-extension/caf-data-jpa-extension/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java similarity index 100% rename from caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java rename to caf-extension/caf-data-jpa-extension/src/main/java/io/iec/edp/caf/commons/transaction/Impl/DBTransactionServiceImpl.java diff --git a/caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java b/caf-extension/caf-data-jpa-extension/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java similarity index 100% rename from caf-data/caf-data-jpa/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java rename to caf-extension/caf-data-jpa-extension/src/main/java/io/iec/edp/caf/commons/transaction/persistence/EcpDBTransactionWarningRpcPersistence.java -- Gitee From c7ac3ced1a1f80070b7a02f708b6c0d32f780e63 Mon Sep 17 00:00:00 2001 From: hanshuai03 <14693422+hanshuai03@user.noreply.gitee.com> Date: Tue, 13 Jan 2026 14:37:32 +0800 Subject: [PATCH 3/4] =?UTF-8?q?jpa=E4=B8=BB=E5=BA=93=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=8C=96=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- caf-extension/caf-data-jpa-extension/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/caf-extension/caf-data-jpa-extension/pom.xml b/caf-extension/caf-data-jpa-extension/pom.xml index b36acf4d7..704e99f5a 100644 --- a/caf-extension/caf-data-jpa-extension/pom.xml +++ b/caf-extension/caf-data-jpa-extension/pom.xml @@ -5,7 +5,7 @@ 4.0.0 io.iec.edp - caf-framework + caf-extension 1.9.5-SNAPSHOT -- Gitee From 7715734c41703771dfbefe29f411e354a6c7fc41 Mon Sep 17 00:00:00 2001 From: hanshuai03 <14693422+hanshuai03@user.noreply.gitee.com> Date: Tue, 13 Jan 2026 14:51:44 +0800 Subject: [PATCH 4/4] =?UTF-8?q?jpa=E4=B8=BB=E5=BA=93=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=8C=96=E6=94=B9=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- caf-extension/pom.xml | 1 + pom.xml | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/caf-extension/pom.xml b/caf-extension/pom.xml index efb467ffe..9e3ec390c 100644 --- a/caf-extension/pom.xml +++ b/caf-extension/pom.xml @@ -31,6 +31,7 @@ caf-lock-extension caf-rpc-extension caf-rest-extension + caf-data-jpa-extension diff --git a/pom.xml b/pom.xml index 1ce6edc57..4e395750a 100644 --- a/pom.xml +++ b/pom.xml @@ -1178,6 +1178,11 @@ caf-rpc-extension 1.9.4-SNAPSHOT + + io.iec.edp + caf-data-jpa-extension + 1.9.5-SNAPSHOT + io.iec.edp -- Gitee