Org.hibernate.MappingException:No dialect mapping for JDBC type:-1 workaround

Source: Internet
Author: User

Error code:

[C-sharp]View Plaincopy
  1. Org.hibernate.MappingException:No dialect Mapping for JDBC Type: 1
  2. At Org.hibernate.dialect.TypeNames. Get (typenames.java:79)
  3. At Org.hibernate.dialect.TypeNames. Get (typenames.java:104)
  4. At Org.hibernate.dialect.Dialect.getHibernateTypeName (dialect.java:393)
  5. At Org.hibernate.loader.custom.customloader$metadata.gethibernatetype (customloader.java:582)
  6. At Org.hibernate.loader.custom.customloader$scalarresultcolumnprocessor.performdiscovery (CustomLoader.java:508)
  7. At Org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes (customloader.java:524)
  8. At Org.hibernate.loader.Loader.getResultSet (loader.java:1821)
  9. At Org.hibernate.loader.Loader.doQuery (loader.java:697)
  10. At Org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections (loader.java:259)
  11. At Org.hibernate.loader.Loader.doList (loader.java:2232)
  12. At Org.hibernate.loader.Loader.listIgnoreQueryCache (loader.java:2129)
  13. At Org.hibernate.loader.Loader.list (loader.java:2124)
  14. At Org.hibernate.loader.custom.CustomLoader.list (customloader.java:312)
  15. At Org.hibernate.impl.SessionImpl.listCustomQuery (sessionimpl.java:1723)
  16. At Org.hibernate.impl.AbstractSessionImpl.list (abstractsessionimpl.java:165)
  17. At Org.hibernate.impl.SQLQueryImpl.list (sqlqueryimpl.java:175)
  18. At Com.lawyer.dao.ILawFirmDaoImpl.getHeZuoLawFirms (ilawfirmdaoimpl.java:143)
  19. At Com.lawyer.service.ILawFirmServiceImpl.getHeZuoLawFirms (ilawfirmserviceimpl.java:40)
  20. At Com.lawyer.action.IndexAction.loadHostLawFirm (indexaction.java:110)
  21. At Com.lawyer.action.IndexAction.execute (indexaction.java:54)
  22. At Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
  23. At Sun.reflect.NativeMethodAccessorImpl.invoke (nativemethodaccessorimpl.java:39)
  24. At Sun.reflect.DelegatingMethodAccessorImpl.invoke (delegatingmethodaccessorimpl.java:25)
  25. At Java.lang.reflect.Method.invoke (method.java:597)
  26. At Com.opensymphony.xwork2.DefaultActionInvocation.invokeAction (defaultactioninvocation.java:441)
  27. At Com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly (defaultactioninvocation.java:280)
  28. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:243)
  29. At Com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept (Defaultworkflowinterceptor.java : 165)
  30. At Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:87)
  31. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  32. At Com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept (validationinterceptor.java:252)
  33. At Org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept ( annotationvalidationinterceptor.java:68)
  34. At Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:87)
  35. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  36. At Com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept (conversionerrorinterceptor.java:122 )
  37. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  38. At Com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept (parametersinterceptor.java:195)
  39. At Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:87)
  40. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  41. At Com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept (parametersinterceptor.java:195)
  42. At Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:87)
  43. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  44. At Com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept (Staticparametersinterceptor.java : 179)
  45. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  46. At Org.apache.struts2.interceptor.MultiselectInterceptor.intercept (multiselectinterceptor.java:75)
  47. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  48. At Org.apache.struts2.interceptor.CheckboxInterceptor.intercept (checkboxinterceptor.java:94)
  49. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  50. At Org.apache.struts2.interceptor.FileUploadInterceptor.intercept (fileuploadinterceptor.java:235)
  51. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  52. At Com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept (modeldriveninterceptor.java:89)
  53. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  54. At Com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept (Scopedmodeldriveninterceptor.java : 130)
  55. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  56. At Org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept (debugginginterceptor.java:267)
  57. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  58. At Com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept (chaininginterceptor.java:126)
  59. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  60. At Com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept (prepareinterceptor.java:138)
  61. At Com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept (methodfilterinterceptor.java:87)
  62. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  63. At Com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept (i18ninterceptor.java:165)
  64. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  65. At Org.apache.struts2.interceptor.ServletConfigInterceptor.intercept (servletconfiginterceptor.java:164)
  66. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  67. At Com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept (aliasinterceptor.java:179)
  68. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  69. At Com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept (Exceptionmappinginterceptor.java : 176)
  70. At Com.opensymphony.xwork2.DefaultActionInvocation.invoke (defaultactioninvocation.java:237)
  71. At Org.apache.struts2.impl.StrutsActionProxy.execute (strutsactionproxy.java:52)
  72. At Org.apache.struts2.dispatcher.Dispatcher.serviceAction (dispatcher.java:488)
  73. At Org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction (executeoperations.java:77)
  74. At Org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter ( strutsprepareandexecutefilter.java:91)
  75. At Org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (applicationfilterchain.java:235)
  76. At Org.apache.catalina.core.ApplicationFilterChain.doFilter (applicationfilterchain.java:206)
  77. At Org.apache.catalina.core.StandardWrapperValve.invoke (standardwrappervalve.java:233)
  78. At Org.apache.catalina.core.StandardContextValve.invoke (standardcontextvalve.java:191)
  79. At Org.apache.catalina.core.StandardHostValve.invoke (standardhostvalve.java:128)
  80. At Org.apache.catalina.valves.ErrorReportValve.invoke (errorreportvalve.java:102)
  81. At Org.apache.catalina.core.StandardEngineValve.invoke (standardenginevalve.java:109)
  82. At Org.apache.catalina.connector.CoyoteAdapter.service (coyoteadapter.java:286)
  83. At Org.apache.coyote.http11.Http11Processor.process (http11processor.java:845)
  84. At Org.apache.coyote.http11.http11protocol$http11connectionhandler.process (http11protocol.java:583)
  85. At Org.apache.tomcat.util.net.jioendpoint$worker.run (jioendpoint.java:447)
  86. At Java.lang.Thread.run (thread.java:619)

Workaround: 1

[C-sharp] view Plaincopy
  1. Org.hibernate.MappingException:No dialect Mapping for The JDBC Type: 1 exception is because Hibernate does not support the text type in the database, that is, hibernate does not register the type, and we tend to use this type
  2. Workaround: The simplest is to use the HQL text, without SQL
  3. But sometimes have to use SQL, online a lot of modification of configuration files or create their own class inheritance methods, but the personal feel simple and easy to use the method is to take the data when the CONVERT function, the text into a varchar, simple and convenient
  4. For example: CONVERT (varchar, isnull (BZ, ') )
  5. BZ is the text type variable name, IsNull function to determine whether it is empty

Workaround: 2

[C-sharp] view Plaincopy
  1. Cause: There is a text type field in the database table, and hibernate does not register this field in the native query, so this error occurs.
  2. Workaround: Write a class and modify the hibernate configuration file. Write a dialect subclass, here I extends Mysql5dialect class:
  3. Package xxx.xxx; //xxx.xxx himself according to the situation to write import java.sql.Types;   
  4. Import Org.hibernate.dialect.MySQL5Dialect;
  5. Public class Dialectforinkfish extends Mysql5dialect {
  6. Public Dialectforinkfish () {
  7. Super ();
  8. Registerhibernatetype (Types.longvarchar, 65535, "text");
  9. }
  10. }
  11. Modify Hibernate config file Hibernate.cfg.xml, put
  12. <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
  13. Modified to:
  14. <property name="dialect">com.ibm.crl.inkfish.config.DialectForInkfish</property>

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Org.hibernate.MappingException:No dialect mapping for JDBC type:-1 workaround

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.