solomax commented on code in PR #215:
URL: https://github.com/apache/openjpa/pull/215#discussion_r4256731093


##########
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/flush/TestQueryFlushAccessPath.java:
##########
@@ -0,0 +1,453 @@
+/*
+ * 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.openjpa.persistence.flush;
+
+import java.util.List;
+
+import jakarta.persistence.EntityManager;
+import jakarta.persistence.FlushModeType;
+import jakarta.persistence.criteria.CriteriaBuilder;
+import jakarta.persistence.criteria.CriteriaQuery;
+import jakarta.persistence.criteria.Join;
+import jakarta.persistence.criteria.Root;
+import jakarta.persistence.criteria.Subquery;
+
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+/**
+ * Asserts which dirty instances make a <code>FlushModeType.AUTO</code> query 
flush.
+ * <p>
+ * Section 3.10.8 of the specification scopes the provider's duty to updates
+ * "which could potentially affect the result of the query", and lets the 
provider
+ * discharge it "by flushing those entities to the database or by some other 
means".
+ * OpenJPA's "other means" is the query access path: only a dirty instance of 
a type
+ * the query actually reads can affect its result, so only such an instance 
forces a
+ * flush. The assertions below are on emitted SQL, not on results, because a
+ * full-context flush returns the same results while costing an extra round 
trip.
+ */
+public class TestQueryFlushAccessPath extends SQLListenerTestCase {
+
+    private static final String ANY_UPDATE = "(?i).*UPDATE\\s+FLUSH_.*";
+    private static final String UPDATE_SPOUSE = 
"(?i).*UPDATE\\s+FLUSH_SPOUSE.*";
+    private static final String UPDATE_CUSTOMER = 
"(?i).*UPDATE\\s+FLUSH_CUSTOMER.*";
+    private static final String UPDATE_ORDER = "(?i).*UPDATE\\s+FLUSH_ORDER.*";
+    private static final String INSERT_ORDER = 
"(?i).*INSERT\\s+INTO\\s+FLUSH_ORDER.*";
+    private static final String DELETE_ORDER = 
"(?i).*DELETE\\s+FROM\\s+FLUSH_ORDER.*";
+
+    @Override
+    public void setUp() {
+        setUp(UnenhancedFlushSpouse.class,
+              UnenhancedFlushCustomer.class,
+              UnenhancedFlushOrder.class,
+              UnenhancedFlushExpressOrder.class,
+              "openjpa.RuntimeUnenhancedClasses", "supported",
+              DROP_TABLES);
+
+        EntityManager em = emf.createEntityManager();

Review Comment:
   and below :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to