1.org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
原因:Hibernate框架的方言(Dialect )没有数据库中数据类型nvarchar的映射,只有varchar类型的映射。所以在启动时出现此异常。
解决方法:
方法一:
将数据库字段的nvarchar类型改为varchar类型。
方法二:
为了指定更加明确的返回值类型,我们可以使用addScalar()方法:
session.createSQLQuery("select * from person_inf") .addScalar("name",StandardBasicTypes.STRING) .addScalar("age",StandardBasicTypes.INT) .list();
方法三:
org.hibernate.MappingException: No Dialect mapping for JDBC type: -9 org.hibernate.MappingException: No Dialect mapping for JDBC type: -15
笔者在做连接SQLServer2008数据库的时候遇到了上述的错误,解决办法如下:
package com.shihuan.core.framework.extend; import java.sql.Types; import org.hibernate.Hibernate; import org.hibernate.dialect.SQLServer2008Dialect; public class SqlServer2008Dialect extends SQLServer2008Dialect { public SqlServer2008Dialect() { super(); registerHibernateType(Types.CHAR, Hibernate.STRING.getName()); registerHibernateType(Types.NCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.NVARCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.LONGNVARCHAR, Hibernate.STRING.getName()); registerHibernateType(Types.DECIMAL, Hibernate.DOUBLE.getName()); } } java.sql.Types对应的值请参考http://blog.sina.com.cn/s/blog_4f925fc30102ep0v.html java.sql.Types对应的sql server2008中的一些值: public final static int BIT = -7; public final static int TINYINT = -6; public final static int SMALLINT = 5; public final static int INTEGER = 4; public final static int BIGINT = -5; public final static int FLOAT = 6; public final static int REAL = 7; public final static int DOUBLE = 8; public final static int NUMERIC = 2; public final static int DECIMAL = 3; public final static int CHAR = 1; public final static int VARCHAR = 12; public final static int LONGVARCHAR = -1; public final static int DATE = 91; public final static int TIME = 92; public final static int TIMESTAMP = 93; public final static int BINARY = -2; public final static int VARBINARY = -3; public final static int LONGVARBINARY = -4; public final static int NULL = 0; public final static int OTHER = 1111; public final static int JAVA_OBJECT = 2000; public final static int DISTINCT = 2001; public final static int STRUCT = 2002; public final static int ARRAY = 2003; public final static int BLOB = 2004; public final static int CLOB = 2005; public final static int REF = 2006; public final static int DATALINK = 70; public final static int BOOLEAN = 16; public final static int ROWID = -8; public static final int NCHAR = -15; public static final int NVARCHAR = -9; public static final int LONGNVARCHAR = -16; public static final int NCLOB = 2011; public static final int SQLXML = 2009;
Hibernate SQL方言(hibernate.dialect):
RDBMS |
Dialect |
DB2 |
org.hibernate.dialect.DB2Dialect |
DB2 AS/400 |
org.hibernate.dialect.DB2400Dialect |
DB2 OS390 |
org.hibernate.dialect.DB2390Dialect |
PostgreSQL |
org.hibernate.dialect.PostgreSQLDialect |
MySQL5 |
org.hibernate.dialect.MySQL5Dialect |
MySQL5 with InnoDB |
org.hibernate.dialect.MySQL5InnoDBDialect |
MySQL with MyISAM |
org.hibernate.dialect.MySQLMyISAMDialect |
Oracle(any version) |
org.hibernate.dialect.OracleDialect |
Oracle 9i |
org.hibernate.dialect.Oracle9iDialect |
Oracle 10g |
org.hibernate.dialect.Oracle10gDialect |
Oracle 11g |
org.hibernate.dialect.Oracle10gDialect |
Sybase |
org.hibernate.dialect.SybaseASE15Dialect |
Sybase Anywhere |
org.hibernate.dialect.SybaseAnywhereDialect |
Microsoft SQL Server 2000 |
org.hibernate.dialect.SQLServerDialect |
Microsoft SQL Server 2005 |
org.hibernate.dialect.SQLServer2005Dialect |
Microsoft SQL Server 2008 |
org.hibernate.dialect.SQLServer2008Dialect |
SAP DB |
org.hibernate.dialect.SAPDBDialect |
Informix |
org.hibernate.dialect.InformixDialect |
HypersonicSQL |
org.hibernate.dialect.HSQLDialect |
H2 Database |
org.hibernate.dialect.H2Dialect |
Ingres |
org.hibernate.dialect.IngresDialect |
Progress |
org.hibernate.dialect.ProgressDialect |
Mckoi SQL |
org.hibernate.dialect.MckoiDialect |
Interbase |
org.hibernate.dialect.InterbaseDialect |
Pointbase |
org.hibernate.dialect.PointbaseDialect |
FrontBase |
org.hibernate.dialect.FrontbaseDialect |
Firebird |
org.hibernate.dialect.FirebirdDialect |
1.org.hibernate.MappingException: No Dialect mapping for JDBC type: -9的更多相关文章
- hibernate报错:org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
解决方法:自定义一个Hibernate Dialect. package com.yourcompany.util ; import java.sql.Types; import org.hibern ...
- springboot org.hibernate.MappingException: No Dialect mapping for JDBC type: -9
参考 https://www.cnblogs.com/luxd/p/8316243.html https://www.cnblogs.com/s648667069/p/6478559.html @Co ...
- hibernate:MySQL No Dialect mapping for JDBC type: -1
出处:(hibernate中使用原生的sql语句,报如下错误:) MySQL No Dialect mapping for JDBC type: -1 代码: List list = session. ...
- 关于No Dialect mapping for JDBC type :-9 hibernate执行原生sql语句问题
转自博客http://blog.csdn.net/xd195666916/article/details/5419316,同时感谢博主 今天做了个用hibernate直接执行原生sql的查询,报错No ...
- No Dialect mapping for JDBC type: -1
MySQL数据库中有张表的字段是text,查询出来后对应的java类型是String,Dialect设置为org.hibernate.dialect.MySQLDialect 运行的时候报错:No D ...
- Hibernate映射数据库中longtext类型属性时报错No Dialect mapping for JDBC type: -1的解决方案
出现错误的原因是:hibernate中对于数据库的longtext数据类型不支持. 解决方案: 1.写个类集成方言,然后自己实现对longtext的支持 import java.sql.Types; ...
- Hibernate 数据库方言配置;no dialect mapping for jdbc type:-9;生僻字
最近因为生僻字在界面上显示为?: 主要原因是该字段在数据库中就是varchar类型,显示的就是?:如䶮(yan):现把varchar类型改为nvarchar类型:数据中能够正常显示: 但是Spring ...
- No Dialect mapping for JDBC type: -9
由于项目中使用的是hibernate 4.35版本和sqlserver 2008数据库.所以,自定义方言时,需要和老版本做区别: public class MySQLServerDialect ext ...
- jpa No Dialect mapping for JDBC type:-9
1.自定义个一个继承SQLServerDialect的dialect类 public class MySQLServer2008Dialect extends SQLServer2008Dialect ...
随机推荐
- WPF中timer的使用
Timer控件/ System.Timers.Timer 不能用于WPF中.在WPF中,定时器为 DispatcherTimer. 使用方法如下: private DispatcherTimer ti ...
- JVM ClassLoader加载过程
虚拟机把描述类的数据从Class文件加载到内存,并对数据进行校验.转换解析和初始化,最终形成可以被虚拟机直接使用的Java类型,这就是Java虚拟机的类加载机制. 1)三个类加载器: bootstra ...
- Ubuntu14.04如何备份和恢复系统
清理Ubuntu14.04的系统的垃圾:先清空回收站,软件升级到最新.Ubuntu系统与Windows系统所采用的文件系统不同, Ubuntu系统在使用或更新过程中不会产生文件碎片和垃圾文件,所以在使 ...
- mysql5.6 zip版安装
MySQL安装文件分为两种,一种是msi格式的,一种是zip格式的.如果是msi格式的可以直接点击安装,按照它给出的安装提示进行安装(相信大家的英文可以看懂英文提示),一般MySQL将会安装在C:\P ...
- jQuery渐变弹出层
css: [css]#race{display:block;width:200px;height:50px;line-height:50px;text-align:center;background: ...
- ACID:数据库事务正确执行的四个基本要素
ACID,指数据库事务正确执行的四个基本要素的缩写.包含:原子性(Atomicity).一致性(Consistency).隔离性(Isolation).持久性(Durability).一个支持事务(T ...
- Thinkphp3.2使用scws中文分词 提取关键词
SCWS 是 Simple Chinese Word Segmentation 的首字母缩写(即:简易中文分词系统).1.下载scws官方提供的类(这里使用的是pscws第四版的)http://www ...
- data stage走起
如题,希望以后可以找到相应的工作.(已经工作3年以上了)
- 《零基础学习Python》01
前言 Python是一种跨平台的语言 安装Python(Mac OS X) 1.在www.python.org/downloads 中下载Python,然后像安装其他软件一样进行安装. 2.打开: 找 ...
- Oracle EBS-SQL (BOM-11):检查无BOM的装配件.sql
select msi.segment1, msi.description, . msi.item_type, msi.inventory_item_status_code 状态 from ...