简体   繁体   English

休眠:将多个本机查询分组在一起

[英]Hibernate: Multiple native queries grouped together

I run the following code successfully using hibernate and postgresql 9.1 我使用hibernate和postgresql 9.1成功运行了以下代码

session.createSQLQuery("delete from table_1; delete from table_2").executeUpdate();

My question is: Does hibernate officially support grouping native queries and running them together in one go? 我的问题是: 休眠是否正式支持对本机查询进行分组并一次性运行它们? I was not able to find such information in manual. 我无法在手册中找到此类信息。 Are there any disadvantages or potential risks in using this solution? 使用此解决方案是否有任何不利条件或潜在风险?

You can't execute multiple queries like this, however if you need to execute them like this for any reason you can put these calls in a stored procedure and call that stored procedure. 您无法执行这样的多个查询,但是,如果出于任何原因需要执行这样的查询,可以将这些调用放入存储过程中并调用该存储过程。 However I won't recommend to use a Stored Procedure. 但是,我不建议使用存储过程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM