QuizzesMulti-Tenancy in Hibernate — Concept Check
intermediate
hibernate

Multi-Tenancy in Hibernate — Concept Check

Questions on Multi-Tenancy in Hibernate. Hibernate supports SCHEMA, DATABASE, and DISCRIMINATOR multi-tenancy strategies; the CurrentTenantIdentifierResolver and ConnectionProvider resolve the tenant per request.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Multi-Tenancy in Hibernate — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A company uses the SCHEMA multi-tenancy strategy in Hibernate. What happens if the TenantContext is not cleared after a request?

    • AThe application will throw an exception immediately.
    • BData from the previous tenant might be accessed in subsequent requests.
    • CThe database connection will be terminated.
    • DThe tenant schema will be automatically reset.
  2. 2.In a multi-tenant application using the DATABASE strategy, what could happen if the CurrentTenantIdentifierResolver returns null?

    • AThe default database will be used for the request.
    • BThe request will be ignored and not processed.
    • CThe application will randomly select a database.
    • DAn exception will be thrown due to missing tenant ID.
  3. 3.A developer claims that using the DISCRIMINATOR strategy provides the best data isolation. What is the flaw in this statement?

    • ADISCRIMINATOR is not supported in Hibernate.
    • BDISCRIMINATOR offers the weakest isolation among strategies.
    • CDISCRIMINATOR requires multiple databases.
    • DDISCRIMINATOR needs separate schemas for each tenant.
  4. 4.When using the SCHEMA strategy, how does Hibernate determine which schema to use for a query?

    • AIt uses the schema specified in the application.yml.
    • BIt defaults to the public schema always.
    • CIt randomly selects a schema from the database.
    • DIt uses the schema name from the TenantContext.
  5. 5.A developer sets up a multi-tenant application with AbstractRoutingDataSource but notices tenant data is mixed. What might be the cause?

    • AThe database URLs are incorrectly configured.
    • BThe application uses the wrong Hibernate version.
    • CThe TenantContext is not correctly set per request.
    • DThe application.yml is missing tenant details.
  6. 6.In the SCHEMA strategy, how does Hibernate ensure that SQL statements are executed in the correct tenant's schema?

    • AIt prepends the schema name to every SQL statement.
    • BIt uses a separate database connection for each tenant.
    • CIt appends the schema name to SQL statements.
    • DIt uses a global schema for all tenants.
  7. 7.A developer believes that using the DATABASE strategy simplifies operations compared to DISCRIMINATOR. Why might this be incorrect?

    • ADATABASE does not support tenant isolation.
    • BDATABASE uses a single schema for all tenants.
    • CDATABASE requires tenant_id columns in tables.
    • DDATABASE requires managing multiple database instances.
  8. 8.What role does the CurrentTenantIdentifierResolver play in a multi-tenant Hibernate application?

    • AIt initializes tenant data sources.
    • BIt manages database connections for tenants.
    • CIt resolves the active tenant per request.
    • DIt configures tenant schemas at startup.