简体   繁体   English

使用存储过程保存休眠对象

[英]saving hibernate objects using stored procedure

I have a scenario where-in i need to persist an entity and its dependent objects into database. 我有一种情况,在这种情况下,我需要将一个实体及其从属对象持久保存到数据库中。 I have run into a position where-in i have to insert about 50000 such objects one after the other from a web application. 我遇到了一个位置,我必须从Web应用程序中一个接一个地插入大约50000个这样的对象。 Now doing this in a loop would take about 3 hours to process. 现在,循环执行此过程大约需要3个小时。

I want to change the approach to pass the hibernate entities to a stored procedure and execute them on the database side since this would take considerably lesser time in execution. 我想更改将休眠实体传递给存储过程并在数据库侧执行它们的方法,因为这将大大减少执行时间。

I want to know if this can be done and if yes, how can this be accomplished. 我想知道这是否可以完成,如果可以,如何完成。 The following example can be taken as reference. 以下示例可以作为参考。

Parent A, Parent B - Both may or may not have dependency. 父母A,父母B-两者都可能有或没有依赖性。 Parent C - Independent parent. 父母C-独立父母。 Parent B has 3 children - Child A, Child B, Child C. Child B has also reference to parent C. 父级B有3个孩子-子级A,子级B,子级C。子级B也引用父级C。

I want to change the approach to pass the hibernate entities to a stored procedure 我想更改将休眠实体传递给存储过程的方法

That sounds like a very bad idea. 听起来这是一个非常糟糕的主意。 Like putting bacon in my christmas pudding, both very good but should not be mixed. 就像在我的圣诞布丁中放培根一样,两者都很好,但不应混在一起。

Have you seen hibernate batch its for exactly this problem. 您是否已看到休眠批处理正是针对此问题。

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

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