问题
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