Home:ALL Converter>Insert query not executing in Hibernate but in Oracle

Insert query not executing in Hibernate but in Oracle

Ask Time:2014-03-29T10:09:03         Author:Sandeep

Json Formatter

I made a insert query that is running in Oracle but getting error in Hibernate.

Query:

insert into tmptable
  (dcol1, ncol1, ncol2)
  select TRUNC(hie.timestamp), min(hie.eventid), count(1)
    from eventtable hie
   where hie.eventid >= 123
     and hie.eventtype = 'NEW'
     and hie.key like 'SYS_%'
     and hie.timestamp between trunc(sysdate - 3) and
         trunc(sysdate) + to_dsinterval('00 23:59:59')
   group by TRUNC(hie.timestamp)
   order by TRUNC(hie.timestamp);

When running from Spring MVC + Hibernate, it is giving following error:

HTTP Status 500 - Request processing failed; 
nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected token: 1 near line 1, column 113 [insert into tmp$genutil .....]

Following is the code to insert data:

/* TMP_TABLE_INSERT member variable has above Insert query */
Query query = getSession().createQuery(TMP_TABLE_INSERT);
int result = query.executeUpdate();
System.out.println("Rows affected: " + result);

Can you please suggest what is going wrong here?

Author:Sandeep,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22726128/insert-query-not-executing-in-hibernate-but-in-oracle
yy