Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8609277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:50:46+00:00 2026-06-12T03:50:46+00:00

Using a AbstractMultiTenantConnectionProvider give me some problems. In the case i had 1000 tenants

  • 0

Using a AbstractMultiTenantConnectionProvider give me some problems. In the case i had 1000 tenants and i want to add more without restarting the webserver, how can i use selectConnectionProvider easily?

 @Override
protected ConnectionProvider selectConnectionProvider(String tenantIdentifier) {

if( "xml1".equals(tenantIdentifier) ) 
    return xml1;

if( "xml2".equals(tenantIdentifier) ) 
    return xml2;

return null;
}

As you can see in this example tenants are linked statically. How could i solve this issue. Thanks for any hint or solution! Cheers, t.

Its a follow-up question from here Implement an AbstractMultiTenantConnectionProvider

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T03:50:48+00:00Added an answer on June 12, 2026 at 3:50 am

    Make it a registry (as in the pattern) with which you register/deregister tenants as needed (“as needed” is defined by your app/environment). Structurally then the MultiTenantConnectionProvider internally is a Map. You can access the MultiTenantConnectionProvider from the Hibernate SessionFactory using:

    MultiTenantConnectionProvider multiTenantConnectionProvider = 
    ( (SessionFactoryImplementor) sessionFactory )
            .getServiceRegistry()
            .getService( MultiTenantConnectionProvider.class );
    YourMultiTenantConnectionProviderImpl yourMultiTenantConnectionProvider = (YourMultiTenantConnectionProviderImpl) multiTenantConnectionProvider;
    yourMultiTenantConnectionProvider.registerTenant( ... );
    ...
    yourMultiTenantConnectionProvider.deregisterTenant( ... );
    

    Then you would just need to decide how you want to persist the tenants between starts/stops (write to file, etc). Personally I’d persist immediately upon registerTenant/deregisterTenant calls. Alternately you could wait until shutdown (have YourMultiTenantConnectionProviderImpl implement Stoppable), but you would potentially miss writing some out in cases of JVM crashes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using a populated Table Type as the source for a TSQL-Merge. I want to
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
Using WPF/PRISM I want to log my messages through ILoggerFacade to my GUI (A
using a binary search tree I need to add to a vector all int
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using emacs on Ubuntu 11.10. I want to connect to a SQL Server database
Using Yii, I want to delete all the rows that are not from today.
Using Qt Creator, I have set a QWidget's background property to black. However, some
Using cl-ppcre, I want to discover the number of register groups in a regex,
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.