gpt4 book ai didi

mysql - 错误 org.hibernate.MappingException : No Dialect mapping for JDBC type: -1

转载 作者:行者123 更新时间:2023-11-29 12:56:42 25 4
gpt4 key购买 nike

我在我的一个开发环境中遇到了一个奇怪的问题。安装了新的 mysql 5.5 服务器,在运行我的 spring/hibernate 应用程序时,遇到此错误。

Caused by: org.hibernate.MappingException: No Dialect mapping for JDBC type: -1
at org.hibernate.dialect.TypeNames.get(TypeNames.java:79) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.dialect.TypeNames.get(TypeNames.java:104) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:393) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.custom.CustomLoader$Metadata.getHibernateType(CustomLoader.java:582) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.custom.CustomLoader$ScalarResultColumnProcessor.performDiscovery(CustomLoader.java:508) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:524) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.Loader.getResultSet(Loader.java:1817) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.Loader.doQuery(Loader.java:697) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:259) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.Loader.doList(Loader.java:2228) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2125) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.Loader.list(Loader.java:2120) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:312) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1722) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:175) ~[hibernate-core-3.3.0.SP1.jar:3.3.0.SP1]
at org.hibernate.ejb.QueryImpl.getResultList(QueryImpl.java:67) ~[hibernate-entitymanager-3.4.0.GA.jar:3.4.0.GA]
... 79 common frames omitted

这是失败的查询:

select count(e.event), GROUP_CONCAT(DISTINCT e.event), GROUP_CONCAT(DISTINCT e.eventid) , GROUP_CONCAT(DISTINCT e.ttid), e.mmth, e.absq, e.year, e.mfnmm, e.retls, GROUP_CONCAT(DISTINCT e.bbn),  e.bplk, GROUP_CONCAT(DISTINCT e.ppd), e.sgm, e.sz, e.fm, e.ppk, e.pkg, e.mch, e.md, e.sw,e.ew,ROUND(sum(e.vol),2),ROUND(sum(e.is),2),ROUND(sum(e.iv),2),ROUND(sum(e.pbv),2),ROUND(sum(e.pbvo),2),ROUND(sum(e.upbva),2), ROUND(sum(e.unpbvo),2),ROUND(sum(e.cv),2), ROUND(sum(e.cva),2),   ROUND(sum(e.chv),2), ROUND(sum(e.chl),2) from s_test_mt e where  e.event is not null and e.event <> ''   and  e.mfnmm in ('Kern') group by e.mfnmm, e.retls, e.mch, e.ppk, e.fm, e.sw, e.ew order by e.ttid asc

我在 spring 中使用以下配置:

<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5InnoDBDialect</prop>

仅当使用 hibernate 运行 native 查询时才会发生该异常。而且它在不同的开发环境和生产环境中运行良好(典型的呃!)。是否是由架构/表等的字符集引起的?

我使用的是hibernate 3.3和spring 3,并使用entitymanager访问mysql innodb版本5.5.37

任何关于从哪里开始寻找的指示将不胜感激。

最佳答案

当我没有按照以下方式向 SQLQuery 提供实体类型时,我遇到了这个问题:

 Query query = session.createSQLQuery(
"select * from stock s where s.activeStock = true")
.addEntity(Stock.class);
List result = query.list();

感谢 mkyong ( http://www.mkyong.com/hibernate/hibernate-native-sql-queries-examples/ )

关于mysql - 错误 org.hibernate.MappingException : No Dialect mapping for JDBC type: -1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23953716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com