I have table with a column as NVARCHAR2
, and I have build my object with hibernate annotations, When i want to insert into DB or fetch from DB the result is something like that "???????",
I have implemented a custom Dialect as follows but it did not work.
public class CustomOracleDialect extends Oracle10gDialect{
public CMSCustomOracleDialect() {
registerHibernateType( Types.NVARCHAR, Hibernate.STRING.getName() );
registerColumnType( Types.VARCHAR, "nvarchar2($1)" );
registerColumnType( Types.CLOB, "nclob" );
registerColumnType( Types.NCLOB, "nclob" );
}
}
Might be a little late but I have just come across this issue aswell and I found that can annotate your hibernate class with
@Nationalized
or
@Type(type="org.hibernate.type.StringNVarcharType")
which makes your element use org.hibernate.type.StringNVarcharType
instead of the VarChar type string
which was introduced into hibernate in release 4.1.10 and above. So that it correctly uses the NVarChar2
type or else it will default back to VarChar2 which then looses your international characters.
Hibernate Jira where this was resolved: https://hibernate.atlassian.net/browse/HHH-5869
And Jboss-Hibernate Documentation: https://docs.jboss.org/hibernate/orm/4.3/devguide/en-US/html/ch08.html#value-national-character-types