You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by aa...@apache.org on 2007/02/21 16:18:33 UTC
svn commit: r510054 - in /cayenne/main/branches/STABLE-1.2/cayenne:
cayenne-java/src/cayenne/java/org/objectstyle/cayenne/wocompat/EOModelProcessor.java
cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt
Author: aadamchik
Date: Wed Feb 21 07:18:32 2007
New Revision: 510054
URL: http://svn.apache.org/viewvc?view=rev&rev=510054
Log:
CAY-752: Importing EOModel gives Cast Exception , no feedback from the user, but the fix looks clean
Modified:
cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/wocompat/EOModelProcessor.java
cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt
Modified: cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/wocompat/EOModelProcessor.java
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/wocompat/EOModelProcessor.java?view=diff&rev=510054&r1=510053&r2=510054
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/wocompat/EOModelProcessor.java (original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-java/src/cayenne/java/org/objectstyle/cayenne/wocompat/EOModelProcessor.java Wed Feb 21 07:18:32 2007
@@ -459,19 +459,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);
@@ -500,6 +496,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-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt
URL: http://svn.apache.org/viewvc/cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt?view=diff&rev=510054&r1=510053&r2=510054
==============================================================================
--- cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt (original)
+++ cayenne/main/branches/STABLE-1.2/cayenne/cayenne-other/release-notes/RELEASE-NOTES-1.2.3.txt Wed Feb 21 07:18:32 2007
@@ -14,4 +14,5 @@
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