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;