openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hthom...@apache.org
Subject svn commit: r1469582 - in /openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa: kernel/BrokerImpl.java meta/ClassMetaData.java
Date Thu, 18 Apr 2013 21:27:23 GMT
Author: hthomann
Date: Thu Apr 18 21:27:23 2013
New Revision: 1469582

URL: http://svn.apache.org/r1469582
Log:
OPENJPA-2325: MappedSuperClass without an @Id causes wrong identity type for the inherited
types - back-ported to 2.0.x Pinaki Poddar's commit to trunk, as well as an additional change
he made specific to 2.0.x.

Modified:
    openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
    openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java

Modified: openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java?rev=1469582&r1=1469581&r2=1469582&view=diff
==============================================================================
--- openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
(original)
+++ openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/kernel/BrokerImpl.java
Thu Apr 18 21:27:23 2013
@@ -4503,7 +4503,11 @@ public class BrokerImpl
         Object oid = ApplicationIds.create(pc, meta);
         if (oid == null)
             return false;
-        return find(oid, null, EXCLUDE_ALL, null, 0) != null;
+        
+        
+        return meta.getVersionField() != null 
+             ? pc.pcGetVersion() != null && find(oid, null, EXCLUDE_ALL, null, 0)
!= null
+             : find(oid, null, EXCLUDE_ALL, null, 0) != null;
     }
 
     public OpenJPAStateManager getStateManager(Object obj) {

Modified: openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?rev=1469582&r1=1469581&r2=1469582&view=diff
==============================================================================
--- openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ openjpa/branches/2.0.x/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Thu Apr 18 21:27:23 2013
@@ -180,7 +180,7 @@ public class ClassMetaData
     private List<Class<?>> _interfaces = null;
     private final Map<Class<?>,Map<String,String>> _ifaceMap = 
     	new HashMap<Class<?>,Map<String,String>>();
-    private int _identity = ID_UNKNOWN;
+    private Integer _identity = null;
     private int _idStrategy = ValueStrategies.NONE;
     private int _accessType = AccessCode.UNKNOWN;
     private boolean _replicated = false;
@@ -430,21 +430,24 @@ public class ClassMetaData
      * primary key fields, and {@link #ID_APPLICATION} otherwise.
      */
     public int getIdentityType() {
-        if (_identity == ID_UNKNOWN) {
-            ClassMetaData sup = getPCSuperclassMetaData();
-            if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
-                _identity = sup.getIdentityType();
-            else if (getPrimaryKeyFields().length > 0)
-                _identity = ID_APPLICATION;
-            else if (isMapped())
-                _identity = ID_DATASTORE;
-            else
-                _identity = _repos.getMetaDataFactory().getDefaults().
+       if (_identity != null) {
+           return _identity;
+       } else {
+           ClassMetaData sup = getPCSuperclassMetaData();
+           if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
+               _identity = sup.getIdentityType();
+           else if (getPrimaryKeyFields().length > 0)
+               _identity = ID_APPLICATION;
+           else if (isMapped())
+               _identity = ID_DATASTORE;
+           else if (isAbstract())
+                   _identity = ID_UNKNOWN;
+           else
+               _identity = _repos.getMetaDataFactory().getDefaults().
                     getDefaultIdentityType();
-        }
-        return _identity;
-    }
-
+       }
+       return _identity;
+     }
     /**
      * The type of identity being used. This will be one of:
      * <ul>
@@ -2497,8 +2500,9 @@ public class ClassMetaData
         _embeddable = meta._embeddable;
         _interface = (meta.isManagedInterface()) ? Boolean.TRUE : Boolean.FALSE;
         setIntercepting(meta.isIntercepting());
+        _abstract = meta.isAbstract();
         _impl = meta.getInterfaceImpl();
-        _identity = meta.getIdentityType();
+        _identity = meta._identity == null ? null : meta.getIdentityType();
         _idStrategy = meta.getIdentityStrategy();
         _seqName = meta.getIdentitySequenceName();
         _seqMeta = null;



Mime
View raw message