Details
-
Bug
-
Status: Closed
-
Critical
-
Resolution: Fixed
-
2.0.5
-
None
-
None
Description
Hello!
We are using cayenne and found a bug in class:
org.apache.cayenne.dba.TypesMapping
follow lines:
public static String getJavaBySqlType(int type, int length, int precision) { if (type == Types.NUMERIC && precision == 0) { type = Types.INTEGER; } return (String) sqlEnumJava.get(new Integer(type)); }
problem occurs when we have NUMERIC(12, 0) which is more then Integer! (Integer has only 10 digets).
And we wish to conver it to Long not to louse any digets.
I can sugest to use sumething like this:
public static String getJavaBySqlType(int type, int length, int precision) { if (type == Types.NUMERIC && precision == 0 && length < 10) { if(length < 10){ type = Types.INTEGER; } else if (length < 20) { type = Types.LONG; } } return (String) sqlEnumJava.get(new Integer(type)); }