advancedMulti-Tenancy in Hibernate — Schema, Database & Discriminator Strategies
What are Hibernate's three multi-tenancy strategies, and what's the core tradeoff between them?
Discriminator (shared schema, shared tables, Hibernate auto-injects a tenant filter into every query — cheapest, weakest isolation), schema-based (separate schema per tenant in one database — moderate cost, moderate isolation), and database-based (separate physical database per tenant — highest cost, strongest isolation). The right choice depends on tenant count and isolation/compliance requirements.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response