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 14:21:58 UTC

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

    [ https://issues.apache.org/jira/browse/CAY-1259?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12755466#action_12755466 ] 

Andrey Razumovsky commented on CAY-1259:
----------------------------------------

Applied for 3.0 branch. Not sure that it is too critical to apply to 2.0 - corresponding DbAttribute can be mapped in modeler as BIGINT for a workaround

> 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.