如何在persistence.xml而不是Entity内配置allocationSize [英] How do I configure allocationSize within persistence.xml instead of Entity

查看:65
本文介绍了如何在persistence.xml而不是Entity内配置allocationSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能对 allocationSize 进行某种重构"以将其放入perssitence.xml中,而不必在每个Entity中进行配置?

Is there any possibility to do a kind of "refactor" of allocationSize in order to put it inside the perssitence.xml instead of having to configure it inside each Entity ?

这是我不想拥有的东西:

here's what I don't want to have :

@SequenceGenerator(name="AGENT_IDAGENT_GENERATOR", sequenceName="AGENT_SEQ", allocationSize=1)

这是我期望的

    <properties>
        <property name="allocationSize" value="1"/>
    </properties>
</persistence-unit>

先感谢

推荐答案

您可以在persistence.xml中使用SessionCustomizer,遍历Session登录名的Sequence对象并设置其预分配大小.

You could use a SessionCustomizer in your persistence.xml, iterate over the Session's login's Sequence objects and set their preallocation size.

分配大小为1,不建议这样做,因为它的性能会很差,使用默认值可能会更好.

An allocation size of 1, it not recommended, it will have poor performance, you may be better off with the default.

这篇关于如何在persistence.xml而不是Entity内配置allocationSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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