如何使用 HQL 查询更改列长度?
我尝试了 session.createSQLQuery("ALTER TABLE People MODIFY address VARCHAR(1000);").executeUpdate();
但这会抛出 org.hibernate.exception.SQLGrammarException: 无法执行本机批量操作查询
经过大量谷歌搜索后,建议使用 HQL 而不是 SQL 查询来进行批量更新。不知道如何使用 HQL 来完成此任务。似乎没有合适的 HQL 文档来更新表中的列长度。
非常感谢您的帮助。
I tried session.createSQLQuery("ALTER TABLE People MODIFY address VARCHAR(1000);").executeUpdate();
but this throws org.hibernate.exception.SQLGrammarException: could not execute native bulk manipulation query
After a lot of googling, the recommendation is to use HQL instead of SQL query to do bulk updates. Not sure how to use HQL to accomplish this. There seems to be no decent HQL documentation for updating column length in a table.
Thanks so much for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我建议您通过
session.connection()
运行此本机 SQL 查询。请参阅16.2.2.1 部分。使用 第 16 章。本机 SQL,它靠近您的 ALTER 查询。
其余的一切取决于您的数据库供应商。祝你好运!
I suggest you to run this native SQL query via
session.connection()
.See section 16.2.2.1. Rules/limitations for using stored procedures of Chapter 16. Native SQL, it's near your ALTER query.
All the rest depends on your database vendor. Good Luck!
我找不到办法。看起来像是一个限制。我添加了一个新字段并在启动时复制了旧字段中的数据!
I could not find a way. Looks like a limitation. I added a new field and copied over data from old field at start-up!