Creating a sequence per entity by default happens to be a side effect of how we deduce certain object names based on the entity name. I guess that having a separate table could be beneficial though, as there might be some possible contention issues with having just a single table on certain databases that coarsen locks.
I found a discussion where we discussed the “hibernate_sequence” approach:
- no real application is using that
- apps that do, most likely don’t care
- apps that do, and do care and just specify the sequence name
From my POV, you can continue using the “hibernate_sequence” approach or the table per sequence approach. Transactions on the table are very short, and the only database that possibly uses table based sequences is MySQL, which as far as I know, does not widen row locks to page locks, so you should be fine.
P.S. Oh, yes, forgot to mention I have single abstract class BaseEntity wich defines ID and all other entities extends this class.
This is why changing/specifying the name in the base entity leads to using the same table for all entities.
what is the right way to upgrade my entities and tables to comply with it.
Hard to say. If I were you, I would just continue using the “hibernate_sequence” approach.