org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法
来源:互联网 发布:雷克萨斯rx350 知乎 编辑:程序博客网 时间:2024/05/01 12:20
org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:56)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:81)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:192)
at org.hibernate.loader.custom.CustomLoader.getHibernateType(CustomLoader.java:161)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:131)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1678)
at org.hibernate.loader.Loader.doQuery(Loader.java:662)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
at org.hibernate.loader.Loader.doList(Loader.java:2145)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2029)
at org.hibernate.loader.Loader.list(Loader.java:2024)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:111)
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1655)
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:164)
at com.book.Interface.impl.BookImpl.selectRondomBook(BookImpl.java:102)
at com.book.test.TestOfBook.testBookRondom(TestOfBook.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
原因:
出现这个问题的原因是 通过 Hibernate createSQLQuery() 方法进行查询,对应表中的列有 text类型的,方言导致的。
解决方法:自已建一个方言,继承于MySQLDialect ,引入 registerHibernateType(Types.LONGVARCHAR, Hibernate.TEXT.getName());
如下:
import java.sql.Types;
import org.hibernate.Hibernate;
import org.hibernate.dialect.MySQLDialect;
public class BlobMySQLDialect extends MySQLDialect {
public BlobMySQLDialect(){
super();
registerHibernateType(Types.LONGVARCHAR, Hibernate.TEXT.getName());
}
}
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法搜藏
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法搜藏
- org.hibernate.MappingException: No Dialect mapping for JDBC type: 3
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -16
- org.hibernate.MappingException: No Dialect mapping for JDBC type:
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -4
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -4
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -9(-*)
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -15的解决方法
- 解决org.hibernate.MappingException: No Dialect mapping for JDBC type: -1(或=x)问题
- hibernate中报org.hibernate.MappingException: No Dialect mapping for JDBC type: -16错误
- Java.Vector.Enumeration
- 开源的JEECMS 2.3.2架构分析-转载
- 遍历.net Hashtable
- PHP中经常用到的Pear类库下载网站
- 同一台计算机上的两个flash应用程序之间传递自定义对象出错
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法
- 动态加载JS文件
- 在Sharepoint 2010中 启用 构建动态字符串 活动
- Struts2的处理流程
- Linux Find 命令精通指南
- jQuery实战中文版 第八章 Ajax代码8-3问题
- 2003 r2 sp2
- cmd常用的8个命令
- 详解 Spring 3.0 基于 Annotation 的依赖注入实现