We are using Hibernate 4.x to achieve multi-tenancy with separate DATABASE per tenant.
We are using the increment strategy provided by Hibernate for ID generation.
The ID generation doesn't happen specific to a tenant.
Is there any way we can restrict the ID generation specific to a tenant, instead of getting from a common cache.
Another issue I have seen is on Server re-start.
After server restart, if the first SQL operation happens for Tenant 1, then Hibernate starts caching the IDs referenced from the Ids from Tenant 1 database. This can create conflicts, if the subsequent operation is performed on other Tenant and it already has the Id value provided by Hibernate cache.
I could have used Sequences for generating the IDs, but MYSQL doesn't support Sequences.
Is there any way to avoid getting the IDs from the common cache?
|