我可以使用hibernate本机SQL查询删除表

sun*_*un2 5 java hibernate sql-drop

我试图使用hibernate本机SQL(createSQLQuery)语句删除临时表.这是代码:

session.createSQLQuery("DROP TABLE tmp_dummy_table").executeUpdate();
Run Code Online (Sandbox Code Playgroud)

但它会让我失望:

SQL Error: 1003, SQLState: 24000
ORA-01003: no statement parsed

Exception while creating tmp_dummy_table tableorg.hibernate.exception.GenericJDBCException: org.hibernate.exception.GenericJDBCException:could not execute query
  at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
        at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
        at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
        at org.hibernate.loader.Loader.doList(Loader.java:2223)
        at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
        at org.hibernate.loader.Loader.list(Loader.java:2099)
        at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:289)
        at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1695)
        at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:142)
        at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:152) ....

你能否在这段代码中说明什么错误?

axt*_*avt 4

从堆栈跟踪来看,您似乎调用了list()而不是executeUpdate(),正如您在代码示例中所写的那样。确保你确实打电话了executeUpdate()