| After going through more of your code, the essential problem seems to stem from the fact that the database sequence increment_by is smaller than the SequenceGenerator allocationSize. The sequence was created automatically when making the table with a bigserial type. This of course wouldn't happen if we rely on schema generation from JPA. You can mark this as a minor bug now , since there is a workaround of setting the allocationSize to the same as the corresponding value in the database, but that may be automated as well. For example in Postgre, the query would be
SELECT "increment" FROM INFORMATION_SCHEMA.sequences WHERE sequence_name = 'seq_test_id_seq';
or
SELECT increment_by FROM "seq_test_id_seq";
In the mean time, setting
<property name="hibernate.id.optimizer.pooled.preferred" value="NONE"/>
is a working bypass without having to change all my entities. However I just searched the docs at http://docs.jboss.org/hibernate/orm/5.0/userGuide/en-US/html_single/ and there is no mention of the id optimizer option. Anyone with load-balancing on multiple server instances would need to know this. We barely got a user base and we already had to expand Tomcat's memory limit to 2GB, because it ran out at 512MB. |