在休眠中保存大量记录的最佳方法 [英] Best way to save the large number of records in hibernate

查看:106
本文介绍了在休眠中保存大量记录的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有5000条记录要保存。从数据库的角度来看,最好的办法是在hibernate中保存单个记录(保存(记录)5000次)还是saveAll(5000条记录的列表)...?由于这种场景经常会提示我最好的一个。

I have 5000 records to be saved. what is the best way in the database point of view, whether to save individual records(save(record) 5000 times) or saveAll(list of 5000 records) in hibernate ...? As this kind of scenarios come regularly suggest me the best one..

推荐答案

在Hibernate中使用批量插入功能。

Use the feature batch Insertion in Hibernate.


批量插入是hibernate强大的功能,当您从其他系统批量导入数据时特别有用。如果您不使用hibernate的批处理功能,那么在插入多条记录时,应用程序的性能可能会显着降低。

Batch Insertion is a powerful feature of hibernate particularly useful when you are importing data from other systems in batch. If you do not use batch feature of hibernate, your application's performance may decrease dramatically at the time of insertion of many records.

这里是简单的比较常规保存和批量插入。

还有官方文档。

这篇关于在休眠中保存大量记录的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆