openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ppod...@apache.org
Subject svn commit: r1436957 - /openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Date Tue, 22 Jan 2013 14:35:32 GMT
Author: ppoddar
Date: Tue Jan 22 14:35:32 2013
New Revision: 1436957

URL: http://svn.apache.org/viewvc?rev=1436957&view=rev
Log:
OPENJPA-2325: Correct evaluation of identity type for MappedSuperclass without an identity
field

Modified:
    openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java

Modified: openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java?rev=1436957&r1=1436956&r2=1436957&view=diff
==============================================================================
--- openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
(original)
+++ openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
Tue Jan 22 14:35:32 2013
@@ -179,7 +179,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;
     
@@ -440,21 +440,25 @@ 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().
-                    getDefaultIdentityType();
-        }
+    	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;
     }
-
+  
     /**
      * The type of identity being used. This will be one of:
      * <ul>
@@ -2511,8 +2515,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