| The way I understood incrementSize is that it's supposed to save us frequent queries to reserve an ID by synchronizing the in-JPA counter with the in-database one every incrementSize inserts, or of course on shutdown.Alternatively it would be safer to first increment it by 50 in the database, then just wait for the in-JPA counter to catch-up. However by my count even if it's set to 1, under the current implementation it will fail the first persist when launched in an existing database, like when you're restarting the application. It will succeed the second time, but only for the same table until the next restart. Another potential problem I thought of (but won't personally encounter any time soon) is if several server instances share the same database, say if they stand behind a load-balancer. The sequence caching will lead to de-synchronization between the two servers as soon as one of them persists an entity, the other one will try using the same ID. I just thought of a way to write a test for the load-balancing act. |