• Как подружить NHibernate и nvarchar2?

    @offan
    How to fix mapping errors in Hibernate(no dialect mapping for JDBC type: -9, Found: nclob, expected: nvarchar2)

    How to resolve these exceptions in Hibernate (with Oracle 11g Database – varchar2, nvarchar2, clob,…)?

    MappingException: No Dialect mapping for JDBC type: -9

    or

    Wrong column type in MIG.LOG for column msg. Found: nclob, expected: nvarchar2(255 char)

    These errors or problems you can fix with using custom dialect, here is a sample code:

    public class MyCustomeOracleDialect extends Oracle10gDialect
    {
    public MyCustomeOracleDialect()
    {
    registerHibernateType( Types.NVARCHAR, Hibernate.STRING.getName() );
    registerColumnType( Types.VARCHAR, "nvarchar($1)" );
    registerColumnType( Types.CLOB, "nclob" );
    registerColumnType( Types.NCLOB, "nclob" );
    }
    }
    Ответ написан
    Комментировать