Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hi,
I heard Oracle toplink have object-type-converter mapping type.
And it automatically convert data between object-value and data-value.
As for mapping file please refer the file below.
If we call setSex("FEMALE") method in application,
The Toplink will execute SQL as below.
"insert into TEST values ( ... 'F' ...) "
And, getSex() will return "FEMALE" or "MALE" instead of "F" or "M".
Is there this kind of function in Hibernate3?
I can't find it from Hibernate3 document.
Any help will be appreciated.
There are a pritial mapping file and POJO file of Oracle Toplink.
(1) mapping xml file
<opm:attribute-mapping xsi:type="toplink:direct-mapping">
<opm:attribute-name>action</opm:attribute-name>
<opm:field table="TEST" name="SEX" xsi:type="opm:column"/>
<opm:converter xsi:type="toplink:object-type-converter">
<toplink:type-mappings>
<toplink:type-mapping>
<toplink:object-value xsi:type="xsd:string">MALE</toplink:object-value>
<toplink:data-value xsi:type="xsd:string">M</toplink:data-value>
</toplink:type-mapping>
<toplink:type-mapping>
<toplink:object-value xsi:type="xsd:string">FEMALE</toplink:object-value>
<toplink:data-value xsi:type="xsd:string">F</toplink:data-value>
</toplink:type-mapping>
</toplink:type-mappings>
</opm:converter>
</opm:attribute-mapping>
(2) POJO java file
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
Hibernate version:3.1.3