openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandeep Shrivastava (JIRA)" <j...@apache.org>
Subject [jira] Created: (OPENJPA-603) Schema Tool discards the size of decimal column
Date Fri, 16 May 2008 19:57:55 GMT
Schema Tool discards the size of decimal column
-----------------------------------------------

                 Key: OPENJPA-603
                 URL: https://issues.apache.org/jira/browse/OPENJPA-603
             Project: OpenJPA
          Issue Type: Bug
          Components: jdbc
    Affects Versions: 1.1.0
         Environment: OpenJPA 1.1.0-SNAPSHOT
version id: openjpa-1.1.0-SNAPSHOT-r422266:653008
Apache svn revision: 422266:653008

os.name: Windows XP
os.version: 5.1
os.arch: x86

java.version: 1.6.0_05
java.vendor: BEA Systems, Inc.
            Reporter: Sandeep Shrivastava


Run the SchemaTool against the following schema defintion file

<?xml version='1.0' encoding='UTF-8'?>
<schemas>
    <schema>
        <table name='t2'>
            <column name='c1' type='integer' type-name='int' size='11'/>
            <column name='c2' type='varchar' size='50'/>
            <column name='c3' type='decimal' size='22'/>
        </table>
    </schema>
</schemas>

Here is the trace log:

985  INFO   [Main Thread] openjpa.Tool - Schema tool running action 'add'.  
This process may take some time.  Enable the org.apache.openjpa.jdbc.Schema logging category
to see messages about the collection of schema data, and the org.apache.openjpa.jdbc.SQL category
to see generated SQL commands.
1078  TRACE  [Main Thread] openjpa.jdbc.SQL - <t 1574411, conn 3516148> 
executing stmnt 4762292 CREATE TABLE t2 (c1 int(11), c2 VARCHAR(50), c3 DECIMAL) TYPE =innodb
1297  TRACE  [Main Thread] openjpa.jdbc.SQL - <t 1574411, conn 3516148> [219 ms] spent
1297  INFO   [Main Thread] openjpa.Tool - Recording schema changes.
1313  INFO   [Main Thread] openjpa.jdbc.JDBC - Shutting down connection pool.

The size argument is not ignored and database specific defaults apply. In mySQL it defaults
to decimal(10,0) whereas for db2 the default is decimal(5,0) as per the IBM docs.

This is because the DECIMAL type is present in the set of fixedSizeTypeNameSet in the DBDictionary
class. During the create table sql construction, the appendSize method skips adding the size
for column types in the fixedSizeTypeNameSet.

protected String appendSize(Column col, String typeName) {
        if (fixedSizeTypeNameSet.contains(typeName.toUpperCase()))
            return typeName;
        // Rest of method ...
}

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


Mime
View raw message