I am using hiberrnate reverse engineering tool [HibernateTools-3.2.0.beta11] with oracle 9i DB which has column of type NVARCHAR. I use ant tasks <hbm2hbmxml /> and <hbm2java /> to generate mapping and java files.
In the hibernate.reveng.xml currently am using following mapping to convert nvarchar column to string.
<type-mapping>
<sql-type jdbc-type="OTHER" hibernate-type="string"/>
</type-mapping>
But with above aproach all the unknown JDBC/DB types including nvarchar will be convreted to String. I want to avoid this and instruct tool to convert only nvarchar to string. Is there any other way with which this can be achieved ?
If I don't use above <type-mapping> tag then all nvarchar columns will be converted to java.io.Serializable.
I tried extending Oracle9iDialect and used in the hibernate.cfg.xml file during reverse engineering without using <type-mapping> tag in hibernate.reveng.xml, but with no success. Below is the new dialect class which I used.
public class MyOracle9iDialect extends Oracle9iDialect {
public MyOracle9iDialect(){
super();
registerColumnType( Types.CHAR, "nchar(l)" );
registerColumnType( Types.VARCHAR, "nvarchar2($l)" );
registerColumnType( Types.CLOB, "nclob" );
}
}
Thanks.
|