Org. hibernate. mappingexception: No dialect mapping for JDBC Type:-1 Solution

Source: Internet
Author: User

Error code:

Org. hibernate. mappingexception: No dialect mapping for JDBC Type:-1 <br/> at Org. hibernate. dialect. typenames. get (typenames. java: 79) <br/> at Org. hibernate. dialect. typenames. get (typenames. java: 104) <br/> at Org. hibernate. dialect. dialect. gethibernatetypename (dialect. java: 393) <br/> at Org. hibernate. loader. custom. customloader $ metadata. gethibernatetype (customloader. java: 582) <br/> at Org. hibernate. loader. custom. customloader $ scalarresultcolumnprocessor. performdiscovery (customloader. java: 508) <br/> at Org. hibernate. loader. custom. customloader. autodiscovertypes (customloader. java: 524) <br/> at Org. hibernate. loader. loader. getresultset (loader. java: 1821) <br/> at Org. hibernate. loader. loader. doquery (loader. java: 697) <br/> at Org. hibernate. loader. loader. doqueryandinitializenonlazycollections (loader. java: 259) <br/> at Org. hibernate. loader. loader. dolist (loader. java: 2232) <br/> at Org. hibernate. loader. loader. listignorequerycache (loader. java: 2129) <br/> at Org. hibernate. loader. loader. list (loader. java: 2124) <br/> at Org. hibernate. loader. custom. customloader. list (customloader. java: 312) <br/> at Org. hibernate. impl. sessionimpl. listcustomquery (sessionimpl. java: 1723) <br/> at Org. hibernate. impl. abstractsessionimpl. list (abstractsessionimpl. java: 165) <br/> at Org. hibernate. impl. sqlqueryimpl. list (sqlqueryimpl. java: 175) <br/> at com. lawyer. dao. ilawfirmdaoimpl. gethezuolawfirms (ilawfirmdaoimpl. java: 143) <br/> at com. lawyer. service. ilawfirmserviceimpl. gethezuolawfirms (ilawfirmserviceimpl. java: 40) <br/> at com. lawyer. action. indexaction. loadhostlawfirm (indexaction. java: 110) <br/> at com.lawyer.action.indexaction.exe cute (indexaction. java: 54) <br/> at Sun. reflect. nativemethodaccessorimpl. invoke0 (native method) <br/> at Sun. reflect. nativemethodaccessorimpl. invoke (nativemethodaccessorimpl. java: 39) <br/> at Sun. reflect. delegatingmethodaccessorimpl. invoke (delegatingmethodaccessorimpl. java: 25) <br/> at java. lang. reflect. method. invoke (method. java: 597) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invokeaction (defaactionactioninvocation. java: 441) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invokeactiononly (defaactionactioninvocation. java: 280) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 243) <br/> at com. opensymphony. xwork2.interceptor. defaultworkflowinterceptor. dointercept (defaultworkflowinterceptor. java: 165) <br/> at com. opensymphony. xwork2.interceptor. methodfilterinterceptor. intercept (methodfilterinterceptor. java: 87) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.validator. validationinterceptor. dointercept (validationinterceptor. java: 252) <br/> at Org. apache. struts2.interceptor. validation. annotationvalidationinterceptor. dointercept (annotationvalidationinterceptor. java: 68) <br/> at com. opensymphony. xwork2.interceptor. methodfilterinterceptor. intercept (methodfilterinterceptor. java: 87) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. conversionerrorinterceptor. intercept (conversionerrorinterceptor. java: 122) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. parametersinterceptor. dointercept (parametersinterceptor. java: 195) <br/> at com. opensymphony. xwork2.interceptor. methodfilterinterceptor. intercept (methodfilterinterceptor. java: 87) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. parametersinterceptor. dointercept (parametersinterceptor. java: 195) <br/> at com. opensymphony. xwork2.interceptor. methodfilterinterceptor. intercept (methodfilterinterceptor. java: 87) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. staticparametersinterceptor. intercept (staticparametersinterceptor. java: 179) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at Org. apache. struts2.interceptor. multiselectinterceptor. intercept (multiselectinterceptor. java: 75) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at Org. apache. struts2.interceptor. checkboxinterceptor. intercept (checkboxinterceptor. java: 94) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at Org. apache. struts2.interceptor. fileuploadinterceptor. intercept (fileuploadinterceptor. java: 235) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. modeldriveninterceptor. intercept (modeldriveninterceptor. java: 89) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. scopedmodeldriveninterceptor. intercept (scopedmodeldriveninterceptor. java: 130) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at Org. apache. struts2.interceptor. debugging. debugginginterceptor. intercept (debugginginterceptor. java: 267) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. chaininginterceptor. intercept (chaininginterceptor. java: 126) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. prepareinterceptor. dointercept (prepareinterceptor. java: 138) <br/> at com. opensymphony. xwork2.interceptor. methodfilterinterceptor. intercept (methodfilterinterceptor. java: 87) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. i18ninterceptor. intercept (i18ninterceptor. java: 165) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at Org. apache. struts2.interceptor. servletconfiginterceptor. intercept (servletconfiginterceptor. java: 164) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. aliasinterceptor. intercept (aliasinterceptor. java: 179) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at com. opensymphony. xwork2.interceptor. predictionmappinginterceptor. intercept (exceptionmappinginterceptor. java: 176) <br/> at com. opensymphony. xwork2.defaactionactioninvocation. invoke (defaactionactioninvocation. java: 237) <br/> at org.apache.struts2.impl.strutsactionproxy.exe cute (strutsactionproxy. java: 52) <br/> at Org. apache. struts2.dispatcher. dispatcher. serviceaction (dispatcher. java: 488) <br/> at org.apache.struts2.dispatcher.ng.executeoperations.exe cuteaction (executeoperations. java: 77) <br/> at Org. apache. struts2.dispatcher. ng. filter. strutsprepareandexecutefilter. dofilter (strutsprepareandexecutefilter. java: 91) <br/> at Org. apache. catalina. core. applicationfilterchain. internaldofilter (applicationfilterchain. java: 235) <br/> at Org. apache. catalina. core. applicationfilterchain. dofilter (applicationfilterchain. java: 206) <br/> at Org. apache. catalina. core. standardwrappervalve. invoke (standardwrappervalve. java: 233) <br/> at Org. apache. catalina. core. standardcontextvalve. invoke (standardcontextvalve. java: 191) <br/> at Org. apache. catalina. core. standardhostvalve. invoke (standardhostvalve. java: 128) <br/> at Org. apache. catalina. valves. errorreportvalve. invoke (errorreportvalve. java: 102) <br/> at Org. apache. catalina. core. standardenginevalve. invoke (standardenginevalve. java: 109) <br/> at Org. apache. catalina. connector. coyoteadapter. service (coyoteadapter. java: 286) <br/> at Org. apache. coyote. http11.http11processor. process (http11processor. java: 845) <br/> at Org. apache. coyote. http11.http11protocol $ http11connectionhandler. process (http11protocol. java: 583) <br/> at org.apache.tomcat.util.net. jioendpoint $ worker. run (jioendpoint. java: 447) <br/> at java. lang. thread. run (thread. java: 619)

 

Solution: 1

Org. hibernate. mappingexception: No dialect mapping for JDBC Type:-1 exception because hibernate does not support the text type in the database, that is, Hibernate does not register this type, this type is often used. </P> <p> solution: the simplest is to use hql, no SQL </P> <p> but sometimes you have to use SQL. There are many ways to modify configuration files or create class inheritance on the Internet, however, I personally think that the simple and easy way to use is to use the convert function to convert text into varchar, which is simple and convenient </P> <p> For example: Convert (varchar (100 ), isnull (BZ, '') </P> <p> BZ is the name of a text variable. The isnull function determines whether it is null. </P> <p>

Solution: 2

Cause: a text field exists in the Database Table, and hibernate does not register this field in the native query. Therefore, this error occurs. <Br/> solution: Write a class and modify the hibernate configuration file. Write a subclass of dialect. Here I use the extends mysql5dialect class: <br/> package XXX. xxx; // XXX. xxx writes import Java as needed. SQL. types; <br/> Import Org. hibernate. dialect. mysql5dialect; <br/> public class dialectforinkfish extends mysql5dialect {<br/> Public dialectforinkfish () {<br/> super (); <br/> registerhibernatetype (types. longvarchar, 65535, "text"); <br/>}< br/> modify the hibernate configuration file hibernate. cfg. <br/> <property name = "dialect"> Org. hibernate. dialect. modify mysql5dialect </property> <br/> to <br/> <property name = "dialect"> COM. IBM. CRL. inkfish. config. dialectforinkfish </property>

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.