Hibernate + MSSQL Server: using both nvarchar and char strings (jtds driver)

840 Views Asked by At

Is it ever possible to use both unicode and non-unicode strings in Hibernate (version 4) and Microsoft SQL server (2008/2012)?

What we have now - customised SQL Server dialect that generate nvarchar for strings:

public class SQLServerUnicodeDialect extends SQLServerDialect {

    public SQLServerUnicodeDialect(){
        super();

        // Use Unicode Characters
        registerColumnType( Types.VARCHAR, "nvarchar($l)" );
...
}

At jdbc level we're using JTDS driver that convert all strings as unicode by default (see parameter sendStringParametersAsUnicode).

So I see 2 problems in the task:

  1. How to say hibernate separate unicode and non-unicode strings?
  2. Which jdbc driver support both string types (looks like JTDS has 1 option - all strings as unicode or no)?

Any thoughts are welcome.

0

There are 0 best solutions below