Menu

#1263 DB copy from MS SQL to HSQLDB with NVARCHAR column leads to no dialect mapping error

None
open
nobody
3
2018-12-22
2016-08-19
Flo
No

It is not possible to copy a table with NVARCHAR field(s) to an HSQLDB database. During table creation in the target I get the error:

Copy failed: No Dialect mapping for JDBC type: -9 (NVARCHAR)

This probably also happens for NCHAR, NCLOB and LONGNVARCHAR

I have seen that the mapping is hard-coded in the CommonHibernateDialect implementations.
I fixed this for me by adding following line in the constructor of HSQLDialectExt:

registerColumnType(Types.NVARCHAR, "varchar");

I have mapped this to varchar because HSQLDB uses by default unicode encoding for character strings:

HyperSQL's default character set is Unicode, therefore all possible character strings can be represented by these types.
(http://hsqldb.org/doc/guide/guide.html)

Also the content of the tab data types displays this mapping:

TYPE_NAME DATA_TYPE PRECISION LITERAL_PREFIX LITERAL_SUFFIX CREATE_PARAMS
NVARCHAR 12 [VARCHAR] 2147483647 ' ' LENGTH

Perhaps it is possible to let the user configure this mapping in future.

Discussion

  • Flo

    Flo - 2016-08-22

    Hi Gerd,

    Thanks. I have tested it and it works now.

    Perhaps it makes sense to adapt the lines

    registerColumnType(Types.NCHAR, "varchar");
    registerColumnType(Types.LONGNVARCHAR, "varchar");
    

    to

    registerColumnType(Types.NCHAR, "char($l)");
    registerColumnType(Types.LONGNVARCHAR, "longvarchar");
    

    and add
    registerColumnType(Types.NCLOB, "longvarchar");

    Regards

    Florian

     

Log in to post a comment.

MongoDB Logo MongoDB