Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.5
    • Fix Version/s: 1.2.5, 3.0 beta 1, 2.0.5
    • Component/s: None
    • Labels:
      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));
          }
      

        Attachments

        1. CAY-1259.patch
          0.8 kB
          Evgeny Ryabitskiy

          Activity

            People

            • Assignee:
              antidote Andrey Razumovsky
              Reporter:
              apparition Evgeny Ryabitskiy
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: