| Raman Singal - The Tenant View Filter pattern is a great way to implement the discriminator strategy with Hibernate (https://msdn.microsoft.com/en-us/library/aa479086.aspx#mlttntda_tvf). No @Filters required. You would set it up as follows:
- Implement the tenant views.
- Configure Hibernate for DATABASE multitenancy.
- Each tenant DataSource uses unique credentials (to trigger filtering at the view level).
- Use an Interceptor to block cross tenant updates (database triggers are an option as well).
In addition to the baseline requirements, this approach has a few bonuses:
- It works with Hibernate CRUD operations
- It works with Hibernate NativeQuery
- It works with external frameworks that by bypass Hibernate (e.g. a 3rd party reporting tool).
It also allows you to run discriminator, schema and database multitenancy simultaneously with the same code base (mentioned in some previous comments). Here's some sample code: https://github.com/RJBTechnology/rjb-blog-multitenancy For step by step details, see my blog post: https://rjbtechnology.com/blog/2017-01/discriminator-multitenancy-with-spring-and-hibernate-no-filters/ |