openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r584972 - in /openjpa/trunk: openjpa-kernel/src/main/java/org/apache/openjpa/kernel/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lifecycle/
Date Mon, 15 Oct 2007 23:21:33 GMT
Author: pcl
Date: Mon Oct 15 16:21:30 2007
New Revision: 584972

URL: http://svn.apache.org/viewvc?rev=584972&view=rev
Log:
OPENJPA-403. Assuming that ignoring the new code is sufficient in cases where the fetch configuration
is unavailable.

Added:
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lifecycle/
    openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lifecycle/TestPessimisticPNonTransToPDirty.java
Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java?rev=584972&r1=584971&r2=584972&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/StateManagerImpl.java
Mon Oct 15 16:21:30 2007
@@ -456,7 +456,7 @@
             // post process for the fetchGroup: if there is a
             // fetchgroup field, then go to the FetchConfiguration
             // to get the required fetch fields.
-            if (fgs != null) {
+            if (fgs != null && fetch != null) {
                 if (fields == null)
                     fields = new BitSet(fmds.length);
                 BitSet fgFields = fetch.requiresFetch(fgs, fmds);

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lifecycle/TestPessimisticPNonTransToPDirty.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lifecycle/TestPessimisticPNonTransToPDirty.java?rev=584972&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lifecycle/TestPessimisticPNonTransToPDirty.java
(added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/lifecycle/TestPessimisticPNonTransToPDirty.java
Mon Oct 15 16:21:30 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.lifecycle;
+
+import javax.persistence.EntityManager;
+
+import org.apache.openjpa.enhance.UnenhancedPropertyAccess;
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.PCState;
+import org.apache.openjpa.persistence.JPAFacadeHelper;
+import org.apache.openjpa.persistence.test.SingleEMTestCase;
+
+public class TestPessimisticPNonTransToPDirty
+    extends SingleEMTestCase {
+
+    public void setUp() {
+        setUp(UnenhancedPropertyAccess.class, CLEAR_TABLES);
+
+        UnenhancedPropertyAccess o = new UnenhancedPropertyAccess();
+        EntityManager em = emf.createEntityManager();
+        em.getTransaction().begin();
+        em.persist(o);
+        em.getTransaction().commit();
+        em.close();
+    }
+
+    public void testPNonTransToPDirty() {
+        em.setOptimistic(false);
+        UnenhancedPropertyAccess o = (UnenhancedPropertyAccess)
+            em.createQuery("select o from UnenhancedPropertyAccess o")
+                .getSingleResult();
+        em.getTransaction().begin();
+        try {
+            Broker b = JPAFacadeHelper.toBroker(em);
+            OpenJPAStateManager sm = b.getStateManager(o);
+            assertEquals(PCState.PNONTRANS, sm.getPCState());
+            o.setLazyField("foo");
+            assertEquals(PCState.PDIRTY, sm.getPCState());
+        } finally {
+                em.getTransaction().rollback();
+        }
+    }
+}
\ No newline at end of file



Mime
View raw message