以编程方式更改hibernate批量大小 [英] Changing hibernate batch size programatically

查看:79
本文介绍了以编程方式更改hibernate批量大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过编程方式更改hibernate.jdbc.batch_size?我知道
hibernate.jdbc.batch_size是一个应用程序级参数,想知道是否可以专门为它使用
而不是其他的。我只会为那些HQL插件更改代码。

大图是我需要在某些场景中引入批量插入以使Web应用程序高性能,但我不想要危害现在正常工作的正常插入。



任何指针都可以帮助

谢谢
Sameer

解决方案

据我所知,您不能更改 SessionFactory 在运行时(这些设置不通过public API公开并且是不可变的)。



换句话说,我会使用另一个 SessionFactory (并在 Configuration >对象中设置 hibernate.jdbc.batch_size 属性用于建立它)在需要它的特定场景中。


Is possible to change hibernate.jdbc.batch_size programmatically? I understand hibernate.jdbc.batch_size is a application level parameter, wanted to know if i can use it specifically for certain HQL inserts and not others. I would change the code only for those HQL inserts

The big picture is that i need to introduce batch inserts to make the web application performant in some scenarios, but i do not want to jeopardize the normal inserts which work right now.

Any pointers would help

thanks Sameer

解决方案

To my knowledge, you can't change the configuration settings of a SessionFactory at runtime (the settings are not exposed via the public API and are immutable).

In other words, I would use another SessionFactory (and set the hibernate.jdbc.batch_size property in the Configuration object used to build it) in the specific scenarios needing it.

这篇关于以编程方式更改hibernate批量大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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