No Dialect mapping for JDBC type: 7

网上搜的

No Dialect mapping for JDBC type: 7
I got this error while I was working with hibernate and SQL Server. Following are the findings I came across. Hope this helps you too rectify this error.

Following questions are relevant to understand this clearly.

What is jdbc type 7?
java.sql.Type.REAL : It is a constant in the java programming language, that identifies SQL type REAL.
Value of this constant is 7. This is the above mentioned jdbc type 7.

What is dialect?
Dialect is the type of the database that hibernate is going to use. Following are the commonly used dialects. These are the subclasses of the org.hibernate.dialect.Dialect for specific databases.

org.hibernate.dialect.HSQLDialect
org.hibernate.dialect.Oracle9Dialect
org.hibernate.dialect.MySQLDialect
org.hibernate.dialect.SQLServerDialect
org.hibernate.dialect.FirebirdDialect
What cause this error to occur?
The database may contain a table with field of datatype real. Hibernate dialect SQLServerDialect doesnot understand this type. So we need to explicitly convert this real type to one that dialect can understand. One way to achieve this is to write a subclass of org.hibernate.dialect.SQLServerDialect.


package co.nr.javaalert.hibernate.dialect;
import java.sql.Types;
public class SubSQLServerDialect extends org.hibernate.dialect.SQLServerDialect{
public SQLServerDialectForBilling() {
super();
registerColumnType(Types.REAL,"number($p,$s)");
registerHibernateType(Types.REAL,"double");
}
}

registerColumnType() method register a type name for a given type code. This step register sql column data type NUMBER(precision,scale) to Types.REAL. Then register this Types.REAL with a data type that can understand hibernate. The recommended Java mapping for the sql REAL type is as a Java float.

Use this subclass instead of org.hibernate.dialect.SQLServerDialect in hibernate.cfg.xml.

Reference
SQL dialects reference/Data structure definition/Data types/Numeric types

Hibernate报错No Dialect mapping for JDBC type: -1

01-17

[code=java]rnorg.apache.jasper.JasperException: org.hibernate.MappingException: No Dialect mapping for JDBC type: -1rn org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:541)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:435)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:728)rn org.apache.struts2.dispatcher.ServletDispatcherResult.doExecute(ServletDispatcherResult.java:159)rn org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:186)rn com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:373)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:277)rn com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:176)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)rn com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:263)rn org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)rn com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:133)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)rn com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:207)rn com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)rn com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)rn org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75)rn com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:248)rn rn[/code]rn查询语句:rnrn[code=sql]rn select Job_User.Us_User,Job_User.Us_Brithday,Job_User.Us_Head,Job_User.Us_RegDate,Job_User.Us_RegMail, Job_User.Us_Address,Job_User.Us_Sex, Job_Reusme.Re_Nation,Job_Reusme.Re_Salary,Job_Reusme.Re_Workexperience,Job_Reusme.Re_Schoolexperience, Job_Reusme.Re_Address,Job_Reusme.Re_Name,Job_Reusme.Re_Nowpay from Job_User INNER JOIN Job_Reusme ON Job_User.Re_ReID=Job_Reusme.Re_ReId where Job_User.Us_User=' test ' ; rnrn[/code]rnrn用的sql语句查询.

关于Hibernate的 No Dialect mapping for JDBC type: -1 知道的进!

03-04

org.hibernate.MappingException: No Dialect mapping for JDBC type: -1rn at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)rn at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)rn at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:192)rn at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:161)rn at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:131)rn at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)rn at org.hibernate.loader.Loader.doQuery(Loader.java:662)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)rn at org.hibernate.loader.Loader.doList(Loader.java:2145)rn at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)rn at org.hibernate.loader.Loader.list(Loader.java:2024)rn at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)rn at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)rn at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)rn at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)rn at com.book.Interface.impl.BookImpl.selectRondomBook(BookImpl.java:102)rn at com.book.test.TestOfBook.testBookRondom(TestOfBook.java:36)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)rn at java.lang.reflect.Method.invoke(Method.java:585)rn at junit.framework.TestCase.runTest(TestCase.java:164)rn at junit.framework.TestCase.runBare(TestCase.java:130)rn at junit.framework.TestResult$1.protect(TestResult.java:106)rn at junit.framework.TestResult.runProtected(TestResult.java:124)rn at junit.framework.TestResult.run(TestResult.java:109)rn at junit.framework.TestCase.run(TestCase.java:120)rn at junit.framework.TestSuite.runTest(TestSuite.java:230)rn at junit.framework.TestSuite.run(TestSuite.java:225)rn at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnrnrn就是这么一个错误。。。请问?什么意思?我 抓耳挠腮中...分数给70...

No Dialect mapping for JDBC type: -1这个问题要怎么解决?

06-09

mysql4.1下会出到No Dialect mapping for JDBC type: -1问题,5.0正常,有什么办法可以解决这个问题?大家帮帮手呀、!急。。。。。rnrn错误提示如下:rnHibernate: select src.uid,src.nickyname,comment.content,comment.create_date from sygd_user as src,sygd_story as dest,sygd_comment as comment where src.id=comment.userId and comment.storyId=dest.id and dest.id= '2' limit ?rnorg.springframework.orm.hibernate3.HibernateSystemException: No Dialect mapping for JDBC type: -1; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -1rn at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:661)rn at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)rn at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)rn at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:339)rn at com.netease.vipnew.activity.dao.HibernateDaoImpl.findPageBySQL(HibernateDaoImpl.java:157)rn at com.netease.vipnew.activity.service.SygdServiceImpl.fetchCommentsById(SygdServiceImpl.java:214)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:310)rn at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:198)rn at $Proxy17.fetchCommentsById(Unknown Source)rn at com.netease.vipnew.activity.service.TestLuckyUserServiceImpl.testFetchUserCount(TestLuckyUserServiceImpl.java:27)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)rn at java.lang.reflect.Method.invoke(Unknown Source)rn at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:163)rn at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)rn at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)rn at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)rn at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)rn at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)rn at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:142)rn at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)rn at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)rn at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)rn at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)rn at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)rn at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)rn at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)rn at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)rnCaused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -1rn at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)rn at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)rn at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:370)rn at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:559)rn at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:485)rn at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:501)rn at org.hibernate.loader.Loader.getResultSet(Loader.java:1794)rn at org.hibernate.loader.Loader.doQuery(Loader.java:674)rn at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)rn at org.hibernate.loader.Loader.doList(Loader.java:2205)rn at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2102)rn at org.hibernate.loader.Loader.list(Loader.java:2097)rn at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)rn at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1699)rn at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)rn at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152)rn at com.netease.vipnew.activity.dao.HibernateDaoImpl$3.doInHibernate(HibernateDaoImpl.java:191)rn at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)rn

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试