How To Alter Varchar To Nvarchar Inwards Mssql Using Hibernate

In my recent assignment I was asked to modify how hibernate creates a tabular array changing varchar fields to nvarchar. The employment is inwards MSSQL nosotros demand an nvarchar to back upwards UTF-8 characters.

We are genuinely using a JDBC MSSQL driver available here:
http://technet.microsoft.com/en-us/library/ms378422.aspx

This driver needs to endure configured within jboss, the server I'm on.

First you lot demand to extend SQLServerDialect as well as override the VARCHAR definition.
package org.kbs.hibernate.dialect;  import java.sql.Types;  import org.hibernate.HibernateException; import org.hibernate.dialect.SQLServerDialect;  populace course of written report MSSQLServerDialect extends SQLServerDialect {   populace UnicodeSQLServerDialect() {   super();      registerColumnType(Types.VARCHAR, "nvarchar($l)");   registerColumnType(Types.BIGINT, "bigint");   registerColumnType(Types.BIT, "bit");  }  } 

Second you lot demand to seat hibernate to role your novel class:
<property name="hibernate.dialect" value="org.kbs.hibernate.dialect.MSSQLServerDialect" /> 

Reference:
http://grepcode.com/file/repo1.maven.org/maven2/org.hibernate/hibernate-core/3.3.1.GA/org/hibernate/dialect/SQLServerDialect.java
Next
Previous
Click here for Comments

0 komentar:

Please comment if there are any that need to be asked.