solomax commented on code in PR #225:
URL: https://github.com/apache/openjpa/pull/225#discussion_r4373670821
##########
openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java:
##########
@@ -625,7 +625,7 @@ public Collection<Object>
loadAll(Collection<OpenJPAStateManager> sms, PCState s
fields = entry.getValue();
cache = _mgr.selectCache(sm);
- if (cache == null || sm.isEmbedded() || (failed != null
+ if (cache == null || sm.isEmbedded() || hasUncommittedState(sm) ||
(failed != null
Review Comment:
`{}` :))
##########
openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/datacache/TestDataCacheLoadDirtyInstance.java:
##########
@@ -0,0 +1,183 @@
+/*
+ * 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.datacache;
+
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAPersistence;
+import org.apache.openjpa.persistence.test.SQLListenerTestCase;
+
+/**
+ * Loading a field of an instance with unflushed changes must not put those
+ * changes in the data cache, since they are lost when the transaction rolls
+ * back.
+ */
+public class TestDataCacheLoadDirtyInstance extends SQLListenerTestCase {
+
+ private static final long ID = 1L;
+
+ @Override
+ public void setUp() {
+ // RefreshFromDataCache lets a refresh go through the data cache, so
+ // that its loaded state is cached
+ super.setUp(CLEAR_TABLES, CachedLazyEntity.class, "openjpa.DataCache",
"true",
+ "openjpa.RefreshFromDataCache", "true");
+
+ OpenJPAEntityManager em = emf.createEntityManager();
Review Comment:
`try-with-resource` ? :)
--
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]