How do I configure allocationSize within persistence.xml instead of Entity

天大地大妈咪最大 提交于 2019-12-11 06:09:35

问题


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)

here's what I'm expecting to have

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

Thank's in advance


回答1:


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

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




回答2:


If wanting a JPA solution, then you can't put it in persistence.xml, just use orm.xml



来源:https://stackoverflow.com/questions/7927826/how-do-i-configure-allocationsize-within-persistence-xml-instead-of-entity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!