gpt4 book ai didi

java - 我可以使用 hibernate native SQL 查询删除表吗

转载 作者:搜寻专家 更新时间:2023-10-31 20:15:13 25 4
gpt4 key购买 nike

我正在尝试使用 hibernate native SQL (createSQLQuery) 语句删除临时表。这是代码:

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

但是它抛出以下异常:

SQL Error: 1003, SQLState: 24000ORA-01003: no statement parsedException 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()

关于java - 我可以使用 hibernate native SQL 查询删除表吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8172510/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com