You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by "Andrey Razumovsky (JIRA)" <ji...@apache.org> on 2009/09/15 10:29:57 UTC

[jira] Assigned: (CAY-1259) Wrong Mapping for NUMERIC Type

     [ https://issues.apache.org/jira/browse/CAY-1259?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrey Razumovsky reassigned CAY-1259:
--------------------------------------

    Assignee: Andrey Razumovsky

> Wrong Mapping for NUMERIC Type
> ------------------------------
>
>                 Key: CAY-1259
>                 URL: https://issues.apache.org/jira/browse/CAY-1259
>             Project: Cayenne
>          Issue Type: Bug
>    Affects Versions: 2.0.5
>            Reporter: Evgeny Ryabitskiy
>            Assignee: Andrey Razumovsky
>            Priority: Critical
>             Fix For: 2.0.5
>
>         Attachments: CAY-1259.patch
>
>
> Hello!
> We are using cayenne and found a bug in class:
> org.apache.cayenne.dba.TypesMapping
> follow lines:
> {code}
>     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));
>     }
> {code}
> 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:
> {code}
>     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));
>     }
> {code}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.