Hibernate query exception: No dialect mapping for JDBC type:-9 (SQL Server)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.