I have to use different values for the allocationSize on one sequence, depending on where it is called (either from a batch or from the normal process).
I currently do that by changing the source code, rebuilding and launching the process, which is far from perfect and can lead to issues.
I have tried using 2 entities for the same table with just a different @SequenceGenerator but JPA/Hibernate doesn't quite like it:
org.hibernate.HibernateException: Multiple references to database sequence [my_sequence] were encountered attempting to set conflicting values for 'increment size'. Found [100] and [1]
I have tried rewriting the annotation at runtime but it seems to be cached even before the first entity is created : the rewrite works well (the allocationSize has the required value before making the first call to the repository) but Hibernate keeps using the value that was set at JVM startup.
I think it could work by creating and using a custom SequenceStyleGenerator (or getting the one from the entity) but I have no clue how to do that.
I'm running out of ideas on how to solve that so any advice would be welcome.
Thanks, Loceka.
PS: we're using JPA 2.1.4 with Hibernate 5.3.7 in Spring Boot 2.1.2