Hi,
I am using the latest Artifact Extractor in Eclispe 3.1M5 to build the Hibernate XML mapping (hbm.xml) and the java Pojo classes. For testing purpose, I am doing the extraction on a MySQL database. And I have this strange issue, the java Pojo set most field like java.lang.Character, but it should be set as String. It seems that all DB table column set as Char(##) are transpose as a java.lang.Character in the Pojo... Is that a Bug?
Here the database ddl:
Code:
create table GNDIVI00 (
DIDIVI CHAR(6) default ' ' not null,
DINOM CHAR(40) default ' ' not null,
DIUSAR CHAR(10) default ' ' not null,
DIREST CHAR(1) default ' ' not null,
DIDATC NUMERIC(8) default 0 not null,
DIHRSC NUMERIC(4) default 0 not null,
DIUSAC CHAR(10) default ' ' not null,
DIDATM NUMERIC(8) default 0 not null,
DIHRSM NUMERIC(4) default 0 not null,
DIUSAM CHAR(10) default ' ' not null,
constraint PK_GNDIVI00 primary key (DIDIVI)
)
here the the Pojo:
Code:
// default package
/**
* Gndivi00 generated by hbm2java
*/
public class Gndivi00 implements java.io.Serializable {
// Fields
private java.lang.Character Didivi;
private java.lang.Character Dinom;
private java.lang.Character Diusar;
private java.lang.Character Direst;
private java.math.BigDecimal Didatc;
private java.math.BigDecimal Dihrsc;
private java.lang.Character Diusac;
private java.math.BigDecimal Didatm;
private java.math.BigDecimal Dihrsm;
private java.lang.Character Diusam;
// Constructors
/** default constructor */
public Gndivi00() {
}
/** constructor with id */
public Gndivi00(java.lang.Character Didivi) {
this.Didivi = Didivi;
}
// Property accessors
/**
*/
public java.lang.Character getDidivi () {
return this.Didivi;
}
public void setDidivi (java.lang.Character Didivi) {
this.Didivi = Didivi;
}
/**
*/
public java.lang.Character getDinom () {
return this.Dinom;
}
public void setDinom (java.lang.Character Dinom) {
this.Dinom = Dinom;
}
etc...
and here'es the hbm.xml:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<!--
Auto-generated mapping file from
the hibernate.org cfg2hbm engine
-->
<class
name="Gndivi00"
table="gndivi00"
catalog=""
>
<id
name="Didivi"
type="java.lang.Character"
>
<column name="DIDIVI" length="6" not-null="true" sql-type="char" />
<generator class="assigned" />
</id>
<property
name="Dinom"
type="java.lang.Character"
>
<column name="DINOM" length="40" not-null="true" sql-type="char" />
</property>
<property
name="Diusar"
type="java.lang.Character"
>
<column name="DIUSAR" length="10" not-null="true" sql-type="char" />
</property>
<property
name="Direst"
type="java.lang.Character"
>
<column name="DIREST" length="1" not-null="true" sql-type="char" />
</property>
<property
name="Didatc"
type="java.math.BigDecimal"
>
<column name="DIDATC" length="8" not-null="true" sql-type="decimal" />
</property>
<property
name="Dihrsc"
type="java.math.BigDecimal"
>
<column name="DIHRSC" length="4" not-null="true" sql-type="decimal" />
</property>
<property
name="Diusac"
type="java.lang.Character"
>
<column name="DIUSAC" length="10" not-null="true" sql-type="char" />
</property>
<property
name="Didatm"
type="java.math.BigDecimal"
>
<column name="DIDATM" length="8" not-null="true" sql-type="decimal" />
</property>
<property
name="Dihrsm"
type="java.math.BigDecimal"
>
<column name="DIHRSM" length="4" not-null="true" sql-type="decimal" />
</property>
<property
name="Diusam"
type="java.lang.Character"
>
<column name="DIUSAM" length="10" not-null="true" sql-type="char" />
</property>
</class>
</hibernate-mapping>
Sorry if I didn't test it; but at first glance, when a method return a "java.lang.Character" it only return 1 character, not 8 or 40...
Any idea? Is it supposed to works ?
Thanks
Etienne
Montreal.