|
From: Francois J. (JIRA) <no...@at...> - 2006-06-24 14:45:36
|
Database columns with non-null integer data type maps to Java "Integer" instead of "int"
-----------------------------------------------------------------------------------------
Key: HBX-693
URL: http://opensource.atlassian.com/projects/hibernate/browse/HBX-693
Project: Hibernate Tools
Type: Patch
Components: reverse-engineer
Versions: 3.1beta5a
Environment: Hibernate 3-2 and Hibernate tool-3.1 beta5
Reporter: Francois Jean
Priority: Minor
Attachments: patch-int.txt
When doing a reverse-engineering on a table with the following database columns:
Column name:Col1, type: Numeric, length: 4, decimal: 0, nullable: false
Column name:Col2, type: Numeric, length: 9, decimal: 0, nullable: false
Column name:Col3, type: Numeric, length: 10, decimal: 0, nullable: false
Col1 will be mapped to java field of type "short"
Col3 will be mapped to java field of type "long"
Col2 will be mapped to java field of type "Integer" !!!
Why col2 is not mapped to a native java type?
I could add the following lines in the xxxx.reveng.xml file to make it happens:
<type-mapping>
<sql-type jdbc-type="DECIMAL" precision="9" scale="0" hibernate-type="int" not-null="true"/>
</type-mapping>
I think that it would be better to have the same comportment for all numerical types.
So, I propose the following patch:
Index: C:/Java/workspace/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCToHibernateTypeHelper.java
===================================================================
--- C:/Java/workspace/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCToHibernateTypeHelper.java (revision 10042)
+++ C:/Java/workspace/HibernateExt/tools/src/java/org/hibernate/cfg/reveng/JDBCToHibernateTypeHelper.java (working copy)
@@ -73,7 +73,7 @@
return returnNullable?Short.class.getName():"short";
}
else if (precision < 10) {
- return returnNullable?Integer.class.getName():"integer";
+ return returnNullable?Integer.class.getName():"int";
}
else if (precision < 19) {
return returnNullable?Long.class.getName():"long";
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
|