0

While using the JPA tablegeneration strategy , we need to mention the allocation size in the @TableGenerator. The default value is 50. We want to override the default allocation size.

But the allocation size needs to be mentioned in every entity. Is there any other better way of doing this ( like configuring it globally or by configuring it as an additional column in the table used for tracking generated Ids )

lives
  • 1,243
  • 5
  • 25
  • 61

2 Answers2

1

Using Plain JPA this does not seem to be possible as noted in these posts:

Setting default allocation size for all entities?

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

It appears that the EclipseLink JPA implementation does provide you with the ability to set this element globally with the `SessionCustomizer'

Community
  • 1
  • 1
Kevin Bowersox
  • 93,289
  • 19
  • 159
  • 189
  • Thanks . We are using hibernate . Is the configuration possible using hibernate ? – lives Nov 29 '12 at 07:25
  • I searched for information on Hibernate and didn't find anything. Doesn't mean its not out there, but I couldn't find it. – Kevin Bowersox Nov 29 '12 at 09:48
  • extending annotations is not supported. Otherwise we can extend the TableGenerator annotation and override the default value i.e. 50. – lives Nov 29 '12 at 12:35
0

I found a workaround using hibernate @genericgenerator. we can override the allocation size by fetching it from table and then reconfiguring the idgenerator

lives
  • 1,243
  • 5
  • 25
  • 61