Author: michiel
Date: 2010-06-01 11:21:51 +0200 (Tue, 01 Jun 2010)
New Revision: 42355

Modified:
   mmbase/branches/MMBase-1_9/core/src/main/java/org/mmbase/core/CoreField.java
Log:
datatype setting can be postponed, so this hack should be repeated then too

Modified: 
mmbase/branches/MMBase-1_9/core/src/main/java/org/mmbase/core/CoreField.java
===================================================================
--- 
mmbase/branches/MMBase-1_9/core/src/main/java/org/mmbase/core/CoreField.java    
    2010-05-31 16:23:18 UTC (rev 42354)
+++ 
mmbase/branches/MMBase-1_9/core/src/main/java/org/mmbase/core/CoreField.java    
    2010-06-01 09:21:51 UTC (rev 42355)
@@ -62,7 +62,7 @@
         // obtain maxlength from datatype where applicable
         if (dataType instanceof LengthDataType) {
             // maxlength is an int, but LengthDataType stores longs.
-            // this ispart of the bridge, so the conflict may be hard to solve
+            // this is part of the bridge, so the conflict may be hard to solve
             // without breaking backward compatibility in the bridge
             long length = ((LengthDataType)dataType).getMaxLength();
             if (length > Integer.MAX_VALUE) {
@@ -73,6 +73,7 @@
         }
     }
 
+
     /**
      * Copy constructor.
      * @param name the name of the data type
@@ -378,8 +379,23 @@
 
     public void setDataType(DataType dataType) throws IllegalArgumentException 
{
         super.setDataType(dataType);
-        // datatype can be influenced by size
-        setMaxLength(maxLength);
+        if (maxLength == -1) { // unset
+            // obtain maxlength from datatype where applicable
+            if (dataType instanceof LengthDataType) {
+                // maxlength is an int, but LengthDataType stores longs.
+                // this is part of the bridge, so the conflict may be hard to 
solve
+                // without breaking backward compatibility in the bridge
+                long length = ((LengthDataType)dataType).getMaxLength();
+                if (length > Integer.MAX_VALUE) {
+                    maxLength = Integer.MAX_VALUE;
+                } else {
+                    maxLength = (int)length;
+                }
+            }
+        } else {
+            // datatype can be influenced by size
+            setMaxLength(maxLength);
+        }
         hashcodeChanged = true;
     }
 

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to