cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r510050 - in /cayenne/main/branches/STABLE-2.0/cayenne: cayenne-java/src/cayenne/java/org/apache/cayenne/wocompat/EOModelProcessor.java cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt
Date Wed, 21 Feb 2007 15:12:50 GMT
Author: aadamchik
Date: Wed Feb 21 07:12:49 2007
New Revision: 510050

URL: http://svn.apache.org/viewvc?view=rev&rev=510050
Log:
CAY-752: Importing EOModel gives Cast Exception , no feedback from the user, but the fix looks
clean

Modified:
    cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/wocompat/EOModelProcessor.java
    cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt

Modified: cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/wocompat/EOModelProcessor.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/wocompat/EOModelProcessor.java?view=diff&rev=510050&r1=510049&r2=510050
==============================================================================
--- cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/wocompat/EOModelProcessor.java
(original)
+++ cayenne/main/branches/STABLE-2.0/cayenne/cayenne-java/src/cayenne/java/org/apache/cayenne/wocompat/EOModelProcessor.java
Wed Feb 21 07:12:49 2007
@@ -423,19 +423,15 @@
                     dbAttr.setEoAttributeName(attrName);
                     dbEntity.addAttribute(dbAttr);
 
-                    Integer width = (Integer) attrMap.get("width");
-                    if (null == width)
-                        width = (Integer) prototypeAttrMap.get("width");
-
-                    if (width != null)
-                        dbAttr.setMaxLength(width.intValue());
-
-                    Integer scale = (Integer) attrMap.get("scale");
-                    if (null == scale)
-                        scale = (Integer) prototypeAttrMap.get("scale");
-
-                    if (scale != null)
-                        dbAttr.setPrecision(scale.intValue());
+                    int width = getInt("width", attrMap, prototypeAttrMap, -1);
+                    if (width >= 0) {
+                        dbAttr.setMaxLength(width);
+                    }
+                    
+                    int scale = getInt("scale", attrMap, prototypeAttrMap, -1);
+                    if (scale >= 0) {
+                        dbAttr.setPrecision(scale);
+                    }
 
                     if (primaryKeys.contains(attrName))
                         dbAttr.setPrimaryKey(true);
@@ -464,6 +460,31 @@
                 // set name instead of the actual attribute, as it may be inherited....
                 attr.setDbAttributeName(dbAttrName);
                 objEntity.addAttribute(attr);
+            }
+        }
+    }
+    
+    int getInt(String key, Map map, Map prototypes, int defaultValue) {
+
+        Object value = map.get(key);
+        if (value == null) {
+            value = prototypes.get(key);
+        }
+
+        if (value == null) {
+            return defaultValue;
+        }
+
+        // per CAY-752, value can be a String or a Number, so handle both
+        if (value instanceof Number) {
+            return ((Number) value).intValue();
+        }
+        else {
+            try {
+                return Integer.parseInt(value.toString());
+            }
+            catch(NumberFormatException nfex) {
+                return defaultValue;
             }
         }
     }

Modified: cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt?view=diff&rev=510050&r1=510049&r2=510050
==============================================================================
--- cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt
(original)
+++ cayenne/main/branches/STABLE-2.0/cayenne/cayenne-other/release-notes/RELEASE-NOTES-2.0-SNAPSHOT.txt
Wed Feb 21 07:12:49 2007
@@ -18,6 +18,7 @@
 CAY-743 Reordering mappings from domain in xml resulting in StackOverflowException
 CAY-750 Stored procedures without parameters fail on Postgres 8
 CAY-751 AS400 datafields containing # in field names do not get mapped correctly
+CAY-752 Importing EOModel gives Cast Exception
 CAY-754 Local jNDI hack breaks when running with Jetty6-Maven
 
 ----------------------------------



Mime
View raw message