openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r446787 - in /incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa: datacache/ kernel/ kernel/jpql/ meta/
Date Fri, 15 Sep 2006 23:49:22 GMT
Author: awhite
Date: Fri Sep 15 16:49:21 2006
New Revision: 446787

URL: http://svn.apache.org/viewvc?view=rev&rev=446787
Log:
Fixes.


Added:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/package.html
Modified:
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataDefaults.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/NoneMetaDataFactory.java

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/datacache/DataCacheStoreManager.java
Fri Sep 15 16:49:21 2006
@@ -20,8 +20,8 @@
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.HashSet;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
@@ -510,13 +510,17 @@
         for (Iterator itr = states.iterator(); itr.hasNext();) {
             sm = (OpenJPAStateManager) itr.next();
 
-            if (sm.getPCState() == PCState.PNEW) {
+            if (sm.getPCState() == PCState.PNEW && !sm.isFlushed()) {
                 if (_inserts == null)
-                    _inserts = new LinkedList();
+                    _inserts = new ArrayList();
                 _inserts.add(sm);
-            } else if (_inserts != null &&
-                (sm.getPCState() == PCState.PNEWDELETED ||
-                sm.getPCState() == PCState.PNEWFLUSHEDDELETED))
+
+                // may have been re-persisted
+                if (_deletes != null)
+                    _deletes.remove(sm);
+            } else if (_inserts != null 
+                && (sm.getPCState() == PCState.PNEWDELETED 
+                || sm.getPCState() == PCState.PNEWFLUSHEDDELETED))
                 _inserts.remove(sm);
             else if (sm.getPCState() == PCState.PDIRTY) {
                 if (_updates == null)
@@ -524,7 +528,7 @@
                 _updates.put(sm, sm.getDirty());
             } else if (sm.getPCState() == PCState.PDELETED) {
                 if (_deletes == null)
-                    _deletes = new LinkedList();
+                    _deletes = new HashSet();
                 _deletes.add(sm);
             }
         }
@@ -572,10 +576,10 @@
      */
     private static class Modifications {
 
-        public final List additions = new LinkedList();
-        public final List newUpdates = new LinkedList();
-        public final List existingUpdates = new LinkedList();
-        public final List deletes = new LinkedList();
+        public final List additions = new ArrayList();
+        public final List newUpdates = new ArrayList();
+        public final List existingUpdates = new ArrayList();
+        public final List deletes = new ArrayList();
     }
 
     private static class PCDataHolder {

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/DetachManager.java
Fri Sep 15 16:49:21 2006
@@ -259,20 +259,17 @@
      * Return a detached version of the given instance.
      */
     public Object detach(Object toDetach) {
-        CallbackException excep = null;
+        List exceps = null;
         try {
             return detachInternal(toDetach);
         } catch (CallbackException ce) {
-            excep = ce;
+            exceps = new ArrayList(1);
+            exceps.add(ce);
             return null; // won't be reached as exception will be rethrown
         } finally {
-            List exceps = null;
-
-            if (excep == null || !_failFast) {
+            if (exceps == null || !_failFast)
                 exceps = invokeAfterDetach(Collections.singleton(toDetach),
-                    null);
-            } else
-                exceps = Collections.singletonList(excep);
+                    exceps);
             if (_detached != null)
                 _detached.clear();
             throwExceptions(exceps);
@@ -303,11 +300,8 @@
                 failFast = true;
             exceps = add(exceps, re);
         } finally {
-            // invoke post callbacks unless all failed
-            if (!failFast && (exceps == null
-                || exceps.size() < instances.size())) {
+            if (!failFast)
                 exceps = invokeAfterDetach(instances, exceps);
-            }
             if (_detached != null)
                 _detached.clear();
         }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/SingleFieldManager.java
Fri Sep 15 16:49:21 2006
@@ -76,8 +76,8 @@
                 if (proxy == null) {
                     proxy = (Proxy) _sm.newFieldProxy(field);
                     ((Date) proxy).setTime(((Date) objval).getTime());
-                    if (proxy instanceof Timestamp &&
-                        objval instanceof Timestamp)
+                    if (proxy instanceof Timestamp 
+                        && objval instanceof Timestamp)
                         ((Timestamp) proxy).setNanos(((Timestamp) objval).
                             getNanos());
                     ret = true;
@@ -89,12 +89,7 @@
                 proxy = checkProxy();
                 if (proxy == null) {
                     proxy = (Proxy) _sm.newFieldProxy(field);
-                    if (objval != null) {
-                        Calendar pcal = (Calendar) proxy;
-                        Calendar ocal = (Calendar) objval;
-                        pcal.setTime(ocal.getTime());
-                        pcal.setTimeZone(ocal.getTimeZone());
-                    }
+                    ((Calendar) proxy).setTime(((Calendar) objval).getTime());
                     ret = true;
                 }
                 break;

Added: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/package.html
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/package.html?view=auto&rev=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/package.html
(added)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/jpql/package.html
Fri Sep 15 16:49:21 2006
@@ -0,0 +1,9 @@
+<html>
+<body>
+<p><strong>JPA Query Language Support</strong></p>
+
+<p>
+    Allow any spec or store to use JPQL.
+</p>
+</body>
+</html>

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/AbstractMetaDataDefaults.java
Fri Sep 15 16:49:21 2006
@@ -40,6 +40,7 @@
         (AbstractMetaDataDefaults.class);
 
     private int _access = ClassMetaData.ACCESS_FIELD;
+    private int _identity = ClassMetaData.ID_UNKNOWN;
     private boolean _ignore = true;
     private boolean _interface = true;
     private boolean _pcRegistry = true;
@@ -63,18 +64,34 @@
 
     /**
      * The default access type for base classes with ACCESS_UNKNOWN.
-     * Returns ACCESS_FIELD by default.
+     * ACCESS_FIELD by default.
+     */
+    public int getDefaultAccessType() {
+        return _access;
+    }
+
+    /**
+     * The default access type for base classes with ACCESS_UNKNOWN.
+     * ACCESS_FIELD by default.
      */
     public void setDefaultAccessType(int access) {
         _access = access;
     }
 
     /**
-     * The default access type for base classes with ACCESS_UNKNOWN.
-     * Returns ACCESS_FIELD by default.
+     * The default identity type for unmapped classes without primary 
+     * key fields. ID_UNKNOWN by default.
      */
-    public int getDefaultAccessType() {
-        return _access;
+    public int getDefaultIdentityType() {
+        return _identity;
+    }
+
+    /**
+     * The default identity type for unmapped classes without primary 
+     * key fields. ID_UNKNOWN by default.
+     */
+    public void setDefaultIdentityType(int identity) {
+        _identity = identity;
     }
 
     public int getCallbackMode() {

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Fri Sep 15 16:49:21 2006
@@ -379,12 +379,13 @@
             ClassMetaData sup = getPCSuperclassMetaData();
             if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
                 _identity = sup.getIdentityType();
-            else {
-                if (getPrimaryKeyFields().length > 0)
-                    _identity = ID_APPLICATION;
-                else 
-                    _identity = (isMapped()) ? ID_DATASTORE : ID_UNKNOWN;
-            }
+            else if (getPrimaryKeyFields().length > 0)
+                _identity = ID_APPLICATION;
+            else if (isMapped())
+                _identity = ID_DATASTORE;
+            else
+                _identity = _repos.getMetaDataFactory().getDefaults().
+                    getDefaultIdentityType();
         }
         return _identity;
     }

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataDefaults.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataDefaults.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataDefaults.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataDefaults.java
Fri Sep 15 16:49:21 2006
@@ -28,10 +28,16 @@
     extends CallbackModes {
 
     /**
-     * Return the default access type for base persistent class with
+     * Return the default access type for a base persistent class with
      * {@link ClassMetaData#ACCESS_UNKNOWN} access type.
      */
     public int getDefaultAccessType();
+
+    /**
+     * Return the default identity type for unmapped classes without primary
+     * key fields.
+     */
+    public int getDefaultIdentityType();
 
     /**
      * What to do on lifecycle callback exceptions.

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/MetaDataRepository.java
Fri Sep 15 16:49:21 2006
@@ -1377,8 +1377,6 @@
      * Update the list of implementations of base classes and interfaces.
      */
     private void updateImpls(Class cls, Class leastDerived, Class check) {
-        if (!_factory.getDefaults().isDeclaredInterfacePersistent())
-            return;
         // allow users to query on common non-pc superclasses
         Class sup = check.getSuperclass();
         if (leastDerived == cls && sup != null && sup != Object.class) {
@@ -1386,6 +1384,10 @@
             updateImpls(cls, leastDerived, sup);
         }
 
+        // allow users to query on any implemented interfaces unless defaults 
+        // say the user must create persistent interfaces explicitly
+        if (!_factory.getDefaults().isDeclaredInterfacePersistent())
+            return;
         Class[] ints = check.getInterfaces();
         for (int i = 0; i < ints.length; i++) {
             // don't map java-standard interfaces

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/NoneMetaDataFactory.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/NoneMetaDataFactory.java?view=diff&rev=446787&r1=446786&r2=446787
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/NoneMetaDataFactory.java
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/NoneMetaDataFactory.java
Fri Sep 15 16:49:21 2006
@@ -93,6 +93,10 @@
         return ClassMetaData.ACCESS_UNKNOWN;
     }
 
+    public int getDefaultIdentityType() {
+        return ClassMetaData.ID_UNKNOWN;
+    }
+
     public int getCallbackMode() {
         return CALLBACK_IGNORE;
     }



Mime
View raw message