I am facing issue while selecting records from datatabase,
Query :
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
Code :
Query query = session.createSQLQuery(query);
Object o = query.uniqueResult();
Stack Trace
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)
I have tried link but it showign Hibernate.Timestamp
can not be resoved by compiler.
hibernate.cfg.xml
<property name="dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
Try it like this:
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With