加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

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

发布时间:2020-12-14 19:16:48 所属栏目:Java 来源:网络整理
导读:我试图使用hibernate本机SQL(createSQLQuery)语句删除临时表. 这是代码: session.createSQLQuery("DROP TABLE tmp_dummy_table").executeUpdate(); 但它会让我失望: SQL Error: 1003,SQLState: 24000ORA-01003: no statement parsedException while creati

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

session.createSQLQuery("DROP TABLE tmp_dummy_table").executeUpdate();

但它会让我失望:

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) ....

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

最佳答案
在您的堆栈跟踪中,当您在代码示例中编写时,它看起来像是调用了list()而不是executeUpdate().确保实际调用executeUpdate().

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读