如何在 persistence.xml 而不是 Entity 中配置 AllocationSize
是否有可能对 allocationSize 进行某种“重构”,以便将其放入 persistence.xml 中,而不必在每个 Entity 中配置它?
这就是我不想拥有的:
@SequenceGenerator(name="AGENT_IDAGENT_GENERATOR", sequenceName="AGENT_SEQ", allocationSize=1)
这就是我期望拥有的
<properties>
<property name="allocationSize" value="1"/>
</properties>
</persistence-unit>
提前致谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 persistence.xml 中使用 SessionCustomizer,迭代会话的登录名序列对象并设置其预分配大小。
分配大小为 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.
如果想要 JPA 解决方案,那么您不能将其放入persistence.xml,只需使用orm.xml
If wanting a JPA solution, then you can't put it in persistence.xml, just use orm.xml