No Dialect mapping for JDBC type:

Source: Internet
Author: User

If there is no problem with using hql statements, there will be a problem through SQL. The reason is that the SQL query field contains the field type such as mediumtext. If an error is reported, an error will be reported in ejb SQL. Just change it to the varchar type.

 

Error Exception:
Org. hibernate. MappingException: No Dialect mapping for JDBC type:-1
At org. hibernate. dialect. TypeNames. get (TypeNames. java: 56)
At org. hibernate. dialect. TypeNames. get (TypeNames. java: 81)


Cause: a text field exists in the Database Table, and Hibernate does not register this field in the native query. Therefore, this error occurs.

Solution: Write a class and modify the hibernate configuration file. Write a subclass of Dialect. Here I use the extends MySQL5Dialect class:
Package xxx. xxx; // xxx. xxx write import java. SQL. Types as needed;
Import org. hibernate. dialect. MySQL5Dialect;
Public class DialectForInkfish extends MySQL5Dialect {
Public DialectForInkfish (){
Super ();
RegisterHibernateType (Types. LONGVARCHAR, 65535, "text ");
}
}
Modify the Hibernate configuration file hibernate. cfg. xml
<Property name = "dialect"> org. hibernate. dialect. MySQL5Dialect </property>
To:
<Property name = "dialect"> com. ibm. crl. inkfish. config. DialectForInkfish </property>
Hibernate ntext:
1. First Use FrontEnd Plus to decompile SQLServerDialect. It is found that SQLServerDialect inherits SybaseDialect and Dialect has the registerHibernateType method. Then, check that the registerColumnType in SybaseDialect structure is not registered with.
This step makes it clear that dialect in Hibernate. cfg. xml does not register the ntext type. Well, register one yourself.
2. Define MySQLServerDialect

  MySQLServerDialect 

3. Use MySQLServerDialect in hibernate. cfg. xml

  

 

Run the program again. Everything is OK.

Link: http://itlife365.com/blog/read.php/472.htm

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.