Java 插入查询不是在Hibernate中执行,而是在Oracle中执行

Java 插入查询不是在Hibernate中执行,而是在Oracle中执行,java,spring,hibernate,Java,Spring,Hibernate,我做了一个在Oracle中运行但在Hibernate中出错的插入查询 查询: 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

我做了一个在Oracle中运行但在Hibernate中出错的插入查询

查询:

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);
从Spring MVC+Hibernate运行时,出现以下错误:

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 .....]
以下是插入数据的代码:

/* 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);

您能建议这里出了什么问题吗?

createQuery
用于创建HQL查询,它是Hibernate的自定义查询语言,类似于SQL


您需要
createSQLQuery

谢谢您的帮助:)