precision/scaling not taken in hbm2hbm in ant env.

Description

For a simple test case, I found precision and scale aren't taken by Hibernate Tool 3.2 beta 8 with MySQL 5. Here is my test case (pay attention to "test" field),

CREATE TABLE `test` (
`id` int(5) NOT NULL,
`test` smallint(2) default NULL,
`comment` char(1) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

<hibernate-reverse-engineering>
<schema-selection match-table="test"/>
<type-mapping>
<!-- jdbc-type is name fom java.sql.Types -->
<sql-type jdbc-type="CHAR" length="1" hibernate-type="yes_no"/>
<sql-type jdbc-type="SMALLINT" hibernate-type="java.lang.Integer"/>
</type-mapping>
<!--sql-type jdbc-type="SMALLINT" precision="2" scale="0" hibernate-type="java.lang.Integer"/-->
<table name="test">
<primary-key>
<generator class="native"/>
</primary-key>
</table>
</hibernate-reverse-engineering>

Form log file I noticed this difference,

1. Without precision and attribute specified

[hibernatetool] (cfg.JDBCBinder 803 ) Building property id
[hibernatetool] (cfg.JDBCBinder 542 ) Scanning org.hibernate.cfg.reveng.TableIdentifier(test) for <version>/<timestamp> columns.
[hibernatetool] (cfg.JDBCBinder 552 ) No columns reported while scanning for <version>/<timestamp> columns in org.hibernate.cfg.reveng.TableIdentifier(test)
[hibernatetool] (reveng.OverrideRepository 312 ) columnToHibernateTypeName, <type-mapping> found: java.lang.Integer for Table: test column: test
[hibernatetool] (cfg.JDBCBinder 635 ) Sql type mismatch for Table: test column: test between DB and wanted hibernate type. Sql type set to 5(SMALLINT) instead of 4(INTEGER)
[hibernatetool] (cfg.JDBCBinder 803 ) Building property test
[hibernatetool] (reveng.OverrideRepository 312 ) columnToHibernateTypeName, <type-mapping> found: yes_no for Table: test column: comment

2. With precision and attribute specified
[hibernatetool] (cfg.JDBCBinder 803 ) Building property id
[hibernatetool] (cfg.JDBCBinder 542 ) Scanning org.hibernate.cfg.reveng.TableIdentifier(test) for <version>/<timestamp> columns.
[hibernatetool] (cfg.JDBCBinder 552 ) No columns reported while scanning for <version>/<timestamp> columns in org.hibernate.cfg.reveng.TableIdentifier(test)
[hibernatetool] (cfg.JDBCBinder 803 ) Building property test
[hibernatetool] (reveng.OverrideRepository 312 ) columnToHibernateTypeName, <type-mapping> found: yes_no for Table: test column: comment

So I can't convert Short to Integer with desired precision/scalling. Original post is at http://forum.hibernate.org/viewtopic.php?t=967518&sid=d73f6dfc4663f78f27f7c36b7d656922

Environment

MySQL 5+Hibernate 3.2GA+XP Pro SP2

Attachments

1

Activity

Show:

Koen Aers December 5, 2024 at 1:58 PM

I am closing this issue as the last relevant update was in 2006. Please feel free to reopen if you feel that this is still relevant.

EricE November 22, 2006 at 8:17 PM

Attached is patch to fix the reporting of scale and precision to reveng and Strategy files. I added SMALLINT, INTEGER, BIGINT, TINYINT to the typeHasScaleAndPrecision because some databases (MySQL) allow specification of scale on these types. I am not sure if the JDBC contract enforces the return of scale for these elements.

Won't Fix

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

EricE
kk
Koen Aers

Components

Fix versions

Affects versions

Priority

Created November 21, 2006 at 5:33 AM
Updated December 5, 2024 at 1:58 PM
Resolved December 5, 2024 at 1:58 PM