gpt4 book ai didi

java - hibernate : No Dialect mapping for JDBC type: 101

转载 作者:搜寻专家 更新时间:2023-10-31 19:54:38 25 4
gpt4 key购买 nike

我在从数据库中选择记录时遇到问题,

查询:

 SELECT rownum as id, mm.metric_name, dm.aggregated_value_float,
dm.created_timestamp, s.type, s.name as subelement_name FROM
daily_metric dm, subelement s, metric_metadata mm WHERE
dm.subelement_id =s.subelement_id AND
TRUNC(dm.created_timestamp)='15-JAN-15' AND s.subelement_id =1456376
and dm.metric_metadata_id = mm.metric_metadata_id order by 1,2 desc

代码:

Query query = session.createSQLQuery(query);
Object o = query.uniqueResult();

堆栈跟踪

org.hibernate.MappingException: No Dialect mapping for JDBC type: 101
at org.hibernate.dialect.TypeNames.get(TypeNames.java:87)
at org.hibernate.dialect.TypeNames.get(TypeNames.java:118)
at org.hibernate.dialect.Dialect.getHibernateTypeName(Dialect.java:653)
at org.hibernate.loader.custom.JdbcResultMetadata.getHibernateType(JdbcResultMetadata.java:93)
at org.hibernate.loader.custom.ScalarResultColumnProcessor.performDiscovery(ScalarResultColumnProcessor.java:62)
at org.hibernate.loader.custom.CustomLoader.autoDiscoverTypes(CustomLoader.java:496)
at org.hibernate.loader.Loader.getResultSet(Loader.java:2073)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1862)
at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:1838)
at org.hibernate.loader.Loader.doQuery(Loader.java:909)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:354)
at org.hibernate.loader.Loader.doList(Loader.java:2551)
at org.hibernate.loader.Loader.doList(Loader.java:2537)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2367)
at org.hibernate.loader.Loader.list(Loader.java:2362)
at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:351)
at org.hibernate.internal.SessionImpl.listCustomQuery(SessionImpl.java:1869)
at org.hibernate.internal.AbstractSessionImpl.list(AbstractSessionImpl.java:311)
at org.hibernate.internal.SQLQueryImpl.list(SQLQueryImpl.java:141)
at org.hibernate.internal.AbstractQueryImpl.uniqueResult(AbstractQueryImpl.java:966)

我试过 link 但它显示 Hibernate.Timestamp 编译器无法解决。

hibernate .cfg.xml

 <property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>

最佳答案

像这样尝试:

Object result = session.createSQLQuery(
"SELECT " +
" rownum as id, " +
" mm.metric_name, " +
" dm.aggregated_value_float, " +
" dm.created_timestamp as dm_timestamp, " +
" s.type, " +
" s.name as subelement_name " +
"FROM " +
" daily_metric dm, " +
" subelement s, " +
" metric_metadata mm " +
"WHERE " +
" dm.subelement_id =s.subelement_id AND " +
" TRUNC(dm.created_timestamp)='15-JAN-15' AND " +
" s.subelement_id =1456376 AND " +
" dm.metric_metadata_id = mm.metric_metadata_id " +
"ORDER BY 1,2 DESC")
.addScalar("dm_timestamp", TimestampType.INSTANCE)
.uniqueResult();

关于java - hibernate : No Dialect mapping for JDBC type: 101,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28044683/

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