Fixed
Details
Assignee
UnassignedUnassignedReporter
Stefanie LiepmannStefanie LiepmannBug 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
Max Rydahl AndersenPatrick DecatStefanie LiepmannSteve EbersoleFix versions
Affects versions
Priority
Minor
Details
Details
Assignee
Unassigned
UnassignedReporter
Stefanie Liepmann
Stefanie LiepmannBug 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
Max Rydahl Andersen
Patrick Decat
Stefanie Liepmann
Steve Ebersole
Fix versions
Affects versions
Priority
Created March 6, 2006 at 5:34 PM
Updated March 21, 2011 at 6:59 PM
Resolved March 11, 2006 at 1:31 AM
I have a table in SQL Server 2000 with the following properties:
Name: Case_ID
DataType: int
Length: 4
Allow Nulls: No
It is the primary key on the table and it uses the identity generator.
I created a hibernate.reveng.xml file and edit it in the Hibernate Reverse Engineering Editor.
The code for the file looks some like this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-reverse-engineering PUBLIC "-//Hibernate/Hibernate Reverse Engineering DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-reverse-engineering-3.0.dtd" >
<hibernate-reverse-engineering>
<table-filter match-catalog="DBName" match-schema="dbo"
match-name="Study" />
<table catalog="DBName" schema="dbo" name="Study">
<primary-key>
<generator class="identity"></generator>
</primary-key>
<column name="Column2" jdbc-type='' />
<!-- more columns here -->
</table>
</hibernate-reverse-engineering>
When it generates the hbm.xml file the code looks like this:
<id name="caseId" type="int">
<column name="Case_ID" />
<generator class="identity"></generator>
</id>
Therefore when I generate the .java code, the Java datatype is a primitive "int". This is not desired since the primary key column should be an object (java.lang.Integer in this case) and not a primitive. Shouldn't the type in the hbm.xml file default to "integer". I know that I can "fix" this behaviour by mapping the datatypes in the "Type Mappings" tab, but I wonder if this is what is intended and if it will frustrate other users. I also noticed a similar problem with the short datatype in that I had to explicitly use "java.lang.Short" when the column allows nulls. Otherwise the hbm2java did not map it correctly. If I am wrong about this, please let me know.