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

换一批

在编写j2ee人过程中碰到org.hibernate.MappingException: No Dialect mapping for JDBC type: -1

04-20

如题 ,我在编写j2ee的过程中碰到了这个问题,查了一些资料,有些人说是在hibernate中没定义过text类型(我的数据库表确实有这个类型的字段)可是我按照它的写法做了。。还是会出问题rn以下是错误rnorg.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 ......................rn我的三个表分别是subarea,reside,userinfornsubarea:id,subareanamernreside: id,sid, rname,content,edituserid-------[color=#FF0000]其中content就是text类型的字段[/color] rnuserinfo:id,userinfo--------等字段 rn其中reside中的sid关联subarea表的id,edituserid关联userinfo的idrn在做j2ee的过程中。它会自动生成pojo([color=#FF0000]所有的pojo以及配置文件都是自动生成的,在更新完数据库后,我把所有的映射,配置都删掉重新弄了,也是用工具自动生成的[/color])rn其中reside.java类的内容为rnprivate Integer id;rn[color=#FF0000]private Userinfo userinfo[/color]rnprivate Subarea subarea;rnprivate String rname;rnprivate String content;rn(**************省略get.set方法*****************)rn[color=#FF0000]它的查询方法是[/color]rn public List indexlist()rn session=HibernateSessionFactory.getSession();rn tryrn sqlquery=session.createSQLQuery("select reside.id,reside.sid,reside.rname,reside.content,reside.edituserid,userinfo.username from reside,userinfo where reside.edituserid=userinfo.id");rn List indexlist=sqlquery.list();rn return indexlist;rn catch(Exception ex)rn ex.printStackTrace();rn System.out.println("分区读取出错");rn return null;rn finallyrn if(session.isOpen())rn session.close();rn rn rn rnrn出现这种错误是为什么啊,在之前我没更新数据库之前(即未加放content字段时就不会出现这种错误)

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