I tried to use the reverse engineering feature of the Eclipse plugin and I have a question about a certain peculiarity I noticed.
The mapping files were generated very well. For example:
Mapping documents:
Code:
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class name="com.allcorp.premium.coverage.data.orm.classes.XatAutoCovrg" table="XAT_AUTO_COVRG" schema="ALLIDB" catalog="R0234376" lazy="false">
<composite-id name="id" class="com.allcorp.premium.coverage.data.orm.classes.XatAutoCovrgId">
<key-property name="AcvProduct" type="java.lang.Character">
<column name="ACV_PRODUCT" scale="8" precision="0" not-null="true" sql-type="CHAR" />
</key-property>
... etc
So, we have a column declared as CHAR(8) in the database.
Here is the code generated for this mapping:Code:
package com.allcorp.premium.coverage.data.orm.classes;
/**
* XatAutoCovrgId generated by hbm2java
*/
public class XatAutoCovrgId implements java.io.Serializable {
// Fields
private java.lang.Character AcvProduct;
private java.lang.Character AcvProductType;
private java.lang.Character AcvVehicleType;
private java.lang.Short AcvVersion;
... etc
Notice how the java type chosen for the CHAR(8) column is a java.lang.Character, which only takes 1 character instead of 8.
Why is
hbm2java doing it this way?
Hibernate version: 3.0.5