Complete setup error note -- No dialect mapping for JDBC Type:-1 error

Source: Internet
Author: User

In order to correct the data after the user misoperations, we intend to add a database management function to query and execute SQL statements on the data table. After half a day, the data in some tables can be properly displayed, but the following error occurs in some tables:

 
No dialect MappingForJDBC Type:-1

Obviously: No dialect can be mapped to JDBC Type-1. Does my database field use a special type, which is not supported by hibernate? Baidu has found many similar errors. Some analyses found that for varchar (Longvarchar) This error is reported during ing. Check the database and find that the text type is used in these tables. This is the reason. There are two ways to modify a field: one is to modify the field type and the other is to extend the custom dialect. The second method is modified as follows:

Add a custom dialect class:

  package   COM. sxpt. util;   Import   JAVA. SQL. types;   Import   Org. hibernate. hibernate;   Import   Org. hibernate. dialect. mysql5dialect;   Public   class  ktmysql5dialect  extends   mysql5dialect {  Public   ktmysql5dialect () {  super   ();   This  . registerhibernatetype (types. longvarchar, hibernate. string. getname () ;} 

Hibernate. xml must also be changed to the corresponding Dialect:

 
<PropertyName= "Hibernate. dialect">Com. sxpt. util. ktmysql5dialect</Property>

AppendixJava. SQL. types value. When an error occurs, you can determine the type based on the value.

 Public   Final   Static   Int Bit =-7 ;  Public   Final  Static   Int Tinyint =-6 ;  Public   Final   Static   Int Smallint = 5 ;  Public   Final   Static   Int Integer = 4 ;  Public   Final   Static  Int Bigint =-5 ;  Public   Final   Static   Int Float = 6 ;  Public   Final   Static   Int Real = 7 ;  Public   Final   Static   Int Double = 8;  Public   Final   Static   Int Numeric = 2 ;  Public   Final   Static   Int Decimal = 3 ;  Public   Final   Static   Int Char = 1 ; Public   Final   Static   Int Varchar = 12 ;  Public   Final   Static   Int Longvarchar =-1 ;  Public   Final   Static   Int Date = 91 ;  Public  Final   Static   Int Time = 92 ;  Public   Final   Static   Int Timestamp = 93 ;  Public   Final   Static   Int Binary =-2 ;  Public   Final  Static   Int Varbinary =-3 ;  Public   Final   Static   Int Longvarbinary =-4 ;  Public   Final   Static   Int Null = 0 ;  Public   Final   Static  Int Others = 1111 ;  Public   Final   Static   Int Java_object = 2000 ;  Public   Final   Static   Int Distinct = 2001 ;  Public   Final   Static   Int Struct = 2002 ;  Public   Final   Static   Int Array = 1, 2003 ;  Public   Final   Static   Int Blob = 2004. ;  Public   Final   Static   Int Clob = 1, 2005;  Public   Final   Static   Int Ref = 2006. ;  Public   Final   Static   Int Datalink = 70 ;  Public   Final   Static   Int Boolean = 16 ; Public   Final   Static   Int Rowid =-8 ;  Public   Static   Final   Int Nchar =-15 ;  Public   Static   Final   Int Nvarchar =-9 ;  Public  Static   Final   Int Longnvarchar =-16 ;  Public   Static   Final   Int Nclob= 2011 ;  Public   Static   Final   Int SQLXML = 2009;

 

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.