openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From awh...@apache.org
Subject svn commit: r441679 - in /incubator/openjpa/trunk: openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/ openjpa-kernel/src/main/java/org/apache/openjpa/meta/ openjpa-kernel/src/main/resources/org/apache/openjpa/meta/ openjpa-persistence/src/main/ja...
Date Fri, 08 Sep 2006 22:45:40 GMT
Author: awhite
Date: Fri Sep  8 15:45:39 2006
New Revision: 441679

URL: http://svn.apache.org/viewvc?view=rev&rev=441679
Log:
Simplify determination of identity type in metadata, also correcting problems
with determining the identity type of hierarchies involving @MappedSuperclasses.


Modified:
    incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/java/org/apache/openjpa/meta/ClassMetaData.java
    incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
    incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java

Modified: incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java?view=diff&rev=441679&r1=441678&r2=441679
==============================================================================
--- incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
(original)
+++ incubator/openjpa/trunk/openjpa-jdbc/src/main/java/org/apache/openjpa/jdbc/meta/MappingRepository.java
Fri Sep  8 15:45:39 2006
@@ -1006,7 +1006,7 @@
                 return ImmutableValueHandler.getInstance();
             case JavaTypes.PC:
                 if (!val.getTypeMapping().isMapped()
-                    && useUntypedPCHandler(val))
+                    && useUntypedPCHandler(val)) 
                     return UntypedPCValueHandler.getInstance();
                 break;
             case JavaTypes.PC_UNTYPED:

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=441679&r1=441678&r2=441679
==============================================================================
--- 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  8 15:45:39 2006
@@ -142,7 +142,7 @@
     private Boolean _embedded = null;
     private Boolean _interface = null;
     private Class _impl = null;
-    private int _identity = -1;
+    private int _identity = ID_UNKNOWN;
     private int _idStrategy = ValueStrategies.NONE;
     private int _accessType = ACCESS_UNKNOWN;
 
@@ -374,23 +374,16 @@
      * primary key fields, and {@link #ID_APPLICATION} otherwise.
      */
     public int getIdentityType() {
-        switch (_identity) {
-            case -1:
-                ClassMetaData sup = getPCSuperclassMetaData();
-                if (sup != null && sup.getIdentityType() != ID_UNKNOWN)
-                    _identity = sup.getIdentityType();
-                else {
-                    FieldMetaData[] pks = getPrimaryKeyFields();
-                    if (pks.length > 0)
-                        _identity = ID_APPLICATION;
-                    else
-                        _identity = ID_DATASTORE;
-                }
-                break;
-            case ID_UNKNOWN:
+        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;
-                break;
+                else 
+                    _identity = (isMapped()) ? ID_DATASTORE : ID_UNKNOWN;
+            }
         }
         return _identity;
     }
@@ -1636,8 +1629,6 @@
      * Validate mapping data.
      */
     protected void validateMapping(boolean runtime) {
-        if (isMapped() && getIdentityType() == ID_UNKNOWN)
-            throw new MetaDataException(_loc.get("mapped-unknownid", this));
     }
 
     /**
@@ -1676,28 +1667,30 @@
      */
     private void validateIdentity(boolean runtime) {
         // make sure identity types are consistent
-        if (_super != null && _identity != -1
-            && getPCSuperclassMetaData().getIdentityType() != _identity)
+        ClassMetaData sup = getPCSuperclassMetaData();
+        int id = getIdentityType();
+        if (sup != null && sup.getIdentityType() != ID_UNKNOWN
+            && sup.getIdentityType() != id)
             throw new MetaDataException(_loc.get("id-types", _type));
 
         // check for things the data store doesn't support
         Collection opts = _repos.getConfiguration().supportedOptions();
-        if (getIdentityType() == ID_APPLICATION
+        if (id == ID_APPLICATION
             && !opts.contains(OpenJPAConfiguration.OPTION_ID_APPLICATION)) {
             throw new UnsupportedException(_loc.get("appid-not-supported",
                 _type));
         }
-        if (getIdentityType() == ID_DATASTORE
+        if (id == ID_DATASTORE
             && !opts.contains(OpenJPAConfiguration.OPTION_ID_DATASTORE)) {
             throw new UnsupportedException(_loc.get
                 ("datastoreid-not-supported", _type));
         }
 
-        if (getIdentityType() == ID_APPLICATION) {
+        if (id == ID_APPLICATION) {
             if (_idStrategy != ValueStrategies.NONE)
                 throw new MetaDataException(_loc.get("appid-strategy", _type));
             validateAppIdClass(runtime);
-        } else
+        } else if (id != ID_UNKNOWN)
             validateNoPKFields();
 
         int strategy = getIdentityStrategy();

Modified: incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties?view=diff&rev=441679&r1=441678&r2=441679
==============================================================================
--- incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
(original)
+++ incubator/openjpa/trunk/openjpa-kernel/src/main/resources/org/apache/openjpa/meta/localizer.properties
Fri Sep  8 15:45:39 2006
@@ -250,9 +250,6 @@
 	access. Only one access method is permitted.
 unsupported-id-type: Type "{0}" declares field "{1}" as a primary key, but \
 	keys of type "{2}" are not supported.
-mapped-unknownid: Type "{0}" is mapped to the data store, but does not have \
-	an identity type.  Alter its metadata to declare datastore identity or \
-	to have at least one primary key field.
 empty-fg-name: Attempt to add an unnamed fetch group to "{0}".
 invalid-fg-depth: Fetch group "{0}" specifies invalid recursion depth "{2}" \
     for field "{1}". Recursion depth must be greater than or equal to -1.

Modified: incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
URL: http://svn.apache.org/viewvc/incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java?view=diff&rev=441679&r1=441678&r2=441679
==============================================================================
--- incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
(original)
+++ incubator/openjpa/trunk/openjpa-persistence/src/main/java/org/apache/openjpa/persistence/AnnotationPersistenceMetaDataParser.java
Fri Sep  8 15:45:39 2006
@@ -472,11 +472,9 @@
         if (isMetaDataMode()) {
             // while the spec only provides for embedded exclusive, it doesn't
             // seem hard to support otherwise
-            if (entity == null) {
+            if (entity == null)
                 meta.setEmbeddedOnly(true);
-                if (_cls.isAnnotationPresent(MappedSuperclass.class))
-                    meta.setIdentityType(ClassMetaData.ID_UNKNOWN);
-            } else {
+            else {
                 meta.setEmbeddedOnly(false);
                 if (!StringUtils.isEmpty(entity.name()))
                     meta.setTypeAlias(entity.name());



Mime
View raw message