org.hibernate.MappingException: No Dialect mapping for JDBC type: -16
来源:互联网 发布:c语言猜数字游戏程序 编辑:程序博客网 时间:2024/05/21 17:33
Java代码:
- public List<Object[]> getPlateNumberAndDate(){
- return getHibernateTemplate().executeFind(new HibernateCallback(){
- public Object doInHibernate(Session session)
- throws HibernateException, SQLException {
- Query q = session.createSQLQuery("SELECT top 5 VEHICLE_NUM, ALARM_DATE FROM [dbo].[ALARM_PROCESS] WHERE CHULI_TAG IS NULL");
- return q.list();
- }
- });
- }
异常:
- Exception in thread "main" org.springframework.orm.hibernate3.HibernateSystemException: No Dialect mapping for JDBC type: -16; nested exception is org.hibernate.MappingException: No Dialect mapping for JDBC type: -16
- at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:676)
- at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
- at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:424)
- at org.springframework.orm.hibernate3.HibernateTemplate.executeFind(HibernateTemplate.java:343)
- at alpha.gpsf.dao.impl.SpeedingQueryDAOImpl.getPlateNumberAndDate(SpeedingQueryDAOImpl.java:43)
- at alpha.gpsf.dao.impl.SpeedingQueryDAOImpl.main(SpeedingQueryDAOImpl.java:106)
- Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -16
- at org.hibernate.dialect.TypeNames.get(TypeNames.java:79)
- at org.hibernate.dialect.TypeNames.get(TypeNames.java:104)
- at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:393)
- at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:582)
- at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:508)
- at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:524)
- at org.hibernate.loader.Loader.getResultSet(Loader.java:1817)
- at org.hibernate.loader.Loader.doQuery(Loader.java:697)
- at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259)
- at org.hibernate.loader.Loader.doList(Loader.java:2228)
- at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125)
- at org.hibernate.loader.Loader.list(Loader.java:2120)
- at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312)
- at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722)
- at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
- at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175)
- at alpha.gpsf.dao.impl.SpeedingQueryDAOImpl$2.doInHibernate(SpeedingQueryDAOImpl.java:48)
- at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:419)
- ... 3 more
关键异常:
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -16
原因:hibernate中native sql对于数据库的某些数据类型不支持,数据类型不能成功映射。
解决办法:
在取数据的时候用下CONVERT函数,把类型转成varchar就行了,测试得知varchar类型没问题
- Query q = session.createSQLQuery("SELECT top 5 CONVERT(varchar(25),VEHICLE_NUM), CONVERT(varchar(25),ALARM_DATE,20) FROM [dbo].[ALARM_PROCESS] WHERE CHULI_TAG IS NULL");
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -16
- org.hibernate.MappingException: No Dialect mapping for JDBC type: 3
- 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:
- 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: -1
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -9(-*)
- hibernate中报org.hibernate.MappingException: No Dialect mapping for JDBC type: -16错误
- 查询blob数据时org.hibernate.MappingException: No Dialect mapping for JDBC type:-4
- 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: 101 Position: 0
- MySQL错误(org.hibernate.MappingException: No Dialect mapping for JDBC type: -4) 解决方案
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -1 解决方法
- hql中常用函數介紹
- Poj 2528 Mayor's posters
- Web服务器和应用服务器的区别
- [zjoi2008]Risk
- 实现Javascript异步编程的4种方法
- org.hibernate.MappingException: No Dialect mapping for JDBC type: -16
- [wc2013]平面图
- 常用JavaScript语法100讲
- Java程序员应该知道的10个调试技巧
- js正则限制input框输入的常用代码
- cuda c并行做哈弗曼编码
- DBGridEh,DBGrid点击标题排序
- JavaScript DOM的本质及操作方法
- hdu2076(时针和分针的夹角)