You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Jacek Laskowski (JIRA)" <ji...@apache.org> on 2007/04/11 00:33:32 UTC

[jira] Created: (OPENJPA-213) @Column with precision and scale should result in NUMERIC(precision, scale)

@Column with precision and scale should result in NUMERIC(precision, scale)
---------------------------------------------------------------------------

                 Key: OPENJPA-213
                 URL: https://issues.apache.org/jira/browse/OPENJPA-213
             Project: OpenJPA
          Issue Type: Improvement
          Components: jpa
    Affects Versions: 0.9.7
            Reporter: Jacek Laskowski


@Column provides the precision and scale attributes, but there's no (easy) way to figure out how it affects the way OpenJPA works if any. It looks like OpenJPA reads the type of a persistent field and when it's double it maps it to DOUBLE in Derby regardless of the other attributes. When precision and scale are specified, a DDL should use NUMERIC(precision, scale) or its synonim - DECIMAL(precision, scale).

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


[jira] Assigned: (OPENJPA-213) @Column with precision and scale should result in NUMERIC(precision, scale)

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/OPENJPA-213?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Dick reassigned OPENJPA-213:
------------------------------------

    Assignee: Michael Dick

> @Column with precision and scale should result in NUMERIC(precision, scale)
> ---------------------------------------------------------------------------
>
>                 Key: OPENJPA-213
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-213
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: jpa
>    Affects Versions: 0.9.7
>            Reporter: Jacek Laskowski
>         Assigned To: Michael Dick
>
> @Column provides the precision and scale attributes, but there's no (easy) way to figure out how it affects the way OpenJPA works if any. It looks like OpenJPA reads the type of a persistent field and when it's double it maps it to DOUBLE in Derby regardless of the other attributes. When precision and scale are specified, a DDL should use NUMERIC(precision, scale) or its synonim - DECIMAL(precision, scale).

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


[jira] Commented: (OPENJPA-213) @Column with precision and scale should result in NUMERIC(precision, scale)

Posted by "Michael Dick (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OPENJPA-213?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12494291 ] 

Michael Dick commented on OPENJPA-213:
--------------------------------------

I'm not sure I agree with the description of the problem. 

I've been basing my assumptions on the conversions tables found at http://java.sun.com/j2se/1.5.0/docs/guide/jdbc/getstart/mapping.html#1004791 

The tables there indicate that a java.lang.Double should be mapped to DOUBLE, not NUMERIC or DECIMAL. If NUMERIC or DECIMAL is desired then the entity should use a variable of type java.math.BigDecimal. 

The way the problem description is worded we'd be changing the rules if precision and scale were specified in an annotation.  It becomes a question of which is more important, the type of the variable or the annotations around it. An argument can be made for either side, but I'm inclined to side with the type of the variable trumping the annotations. I believe the language in the spec supports this interpretation too : 

>From section 9.1.5 
int precision (Optional) The precision for a decimal (exact    0 (Value must be set by
              numeric) column. (Applies only if a decimal col- developer.)
              umn is used.)
int scale     (Optional) The scale for a decimal (exact        0
              numeric) column. (Applies only if a decimal col-
              umn is used.)

Assuming that is the correct approach, there is still a problem with DB2 and Derby where the mapping tool creates a DOUBLE column for BigDecimals instead of a NUMERIC column. I'll use this JIRA to fix the problem with DB2 and Derby.


> @Column with precision and scale should result in NUMERIC(precision, scale)
> ---------------------------------------------------------------------------
>
>                 Key: OPENJPA-213
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-213
>             Project: OpenJPA
>          Issue Type: Improvement
>          Components: jpa
>    Affects Versions: 0.9.7
>            Reporter: Jacek Laskowski
>         Assigned To: Michael Dick
>
> @Column provides the precision and scale attributes, but there's no (easy) way to figure out how it affects the way OpenJPA works if any. It looks like OpenJPA reads the type of a persistent field and when it's double it maps it to DOUBLE in Derby regardless of the other attributes. When precision and scale are specified, a DDL should use NUMERIC(precision, scale) or its synonim - DECIMAL(precision, scale).

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