Today, using Hibernate to query database data (SQL Server), an exception occurred: No dialect mapping for JDBC type:-9
However, copying the corresponding SQL statements to the database UI tool runs the discovery without errors, so consider the issue of hibernate queries.
Finally, by searching the data on the Internet to find hibernate for nvarchar query problem, generally in the Chinese system should use nvarchar as the corresponding type of string, but hibernate in the default implementation sqlserverdialect use varchar.
Workaround:
1. Customizing a dialect class that inherits Sqlserverdialect
public class Mysqlserverdialect extends Sqlserver2008dialect {
Public Mysqlserverdialect () {
Super ();
Registerhibernatetype (Types.nvarchar, StringType.INSTANCE.getName ());
}
}
2. Change Hibernate configuration file: Hibernate1.cfg.xml
The value of Hibernate.dialect is set to your dialect implementation class
<property name= "dialect" >MySQLServerDialect</property>
Restart the operation, solve the!!!!!!
Hibernate query exception: No dialect mapping for JDBC type:-9 (SQL Server)