This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/causeway.git


The following commit(s) were added to refs/heads/main by this push:
     new 3904746e814 CAUSEWAY-3944: refresh entities against DB before passing 
them over to actions (hotfix)
3904746e814 is described below

commit 3904746e8142d74518cacedd5d209cb54ff76995
Author: andi-huber <[email protected]>
AuthorDate: Thu Nov 13 20:57:13 2025 +0100

    CAUSEWAY-3944: refresh entities against DB before passing them over to
    actions (hotfix)
---
 .../runtimeservices/executor/MemberExecutorServiceDefault.java   | 9 +++++++++
 .../publishing/stubs/LifecycleEventPublishingTestAbstract.java   | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java
 
b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java
index bcf9d58cfb0..5e520090a63 100644
--- 
a/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java
+++ 
b/core/runtimeservices/src/main/java/org/apache/causeway/core/runtimeservices/executor/MemberExecutorServiceDefault.java
@@ -39,6 +39,7 @@
 import org.apache.causeway.applib.services.iactnlayer.InteractionLayerTracker;
 import org.apache.causeway.applib.services.inject.ServiceInjector;
 import org.apache.causeway.applib.services.metrics.MetricsService;
+import org.apache.causeway.applib.services.repository.RepositoryService;
 import org.apache.causeway.applib.services.xactn.TransactionService;
 import org.apache.causeway.commons.collections.Can;
 import org.apache.causeway.commons.functional.Try;
@@ -49,6 +50,7 @@
 import 
org.apache.causeway.core.config.progmodel.ProgrammingModelConstants.MessageTemplate;
 import org.apache.causeway.core.metamodel.commons.CanonicalInvoker;
 import org.apache.causeway.core.metamodel.consent.InteractionInitiatedBy;
+import org.apache.causeway.core.metamodel.context.MetaModelContext;
 import org.apache.causeway.core.metamodel.execution.ActionExecutor;
 import org.apache.causeway.core.metamodel.execution.InteractionInternal;
 import org.apache.causeway.core.metamodel.execution.MemberExecutorService;
@@ -105,6 +107,7 @@ public class MemberExecutorServiceDefault
     private final @Getter Provider<ExecutionPublisher> 
executionPublisherProvider;
     private final @Getter MetamodelEventService metamodelEventService;
     private final @Getter TransactionService transactionService;
+    private final @Getter RepositoryService repositoryService;
     private final Provider<CommandPublisher> commandPublisherProvider;
 
     private MetricsService metricsService() {
@@ -140,6 +143,12 @@ private ManagedObject invokeActionInternally(
 
         final ObjectAction owningAction = actionExecutor.getOwningAction();
         final InteractionHead head = actionExecutor.getHead();
+        
+        //CAUSEWAY-3944: make sure entities are in sync with the db before 
passing them to actions
+        if(head.owner().objSpec().isEntity()) {
+               repositoryService.refresh(head.owner().getPojo());
+        }
+        
         final Can<ManagedObject> argumentAdapters = 
actionExecutor.getArguments();
         final InteractionInitiatedBy interactionInitiatedBy = 
actionExecutor.getInteractionInitiatedBy();
         //            final MethodFacade methodFacade,
diff --git 
a/regressiontests/base/src/main/java/org/apache/causeway/testdomain/publishing/stubs/LifecycleEventPublishingTestAbstract.java
 
b/regressiontests/base/src/main/java/org/apache/causeway/testdomain/publishing/stubs/LifecycleEventPublishingTestAbstract.java
index ff4af66be87..2ea097bdc38 100644
--- 
a/regressiontests/base/src/main/java/org/apache/causeway/testdomain/publishing/stubs/LifecycleEventPublishingTestAbstract.java
+++ 
b/regressiontests/base/src/main/java/org/apache/causeway/testdomain/publishing/stubs/LifecycleEventPublishingTestAbstract.java
@@ -180,7 +180,7 @@ protected void verify(
             case ACTION_INVOCATION: // double the book's price action -> 198.0
 
                 assertHasCreatedLifecycleEvents(Can.empty());
-                assertHasLoadedLifecycleEvents(Can.empty());
+                assertHasLoadedLifecycleEvents(bookSample1); //was empty 
before CAUSEWAY-3944
                 assertHasPersistingLifecycleEvents(Can.empty());
                 assertHasPersistedLifecycleEvents(Can.empty());
                 assertHasUpdatingLifecycleEvents(bookSample3);

Reply via email to