Spring boot with Multitenancy unable to switch between tenants

I am using CurrentTenantIdentifierResolver and MultiTenantConnectionProvider, everything works as expected in my test cases and same code that is used in api( controller or service), my tenant is always set to previous. tenant is going to change.

void saveAndLoadPerson() {
      
        currentTenant.setCurrentTenant(main);
       assertThat(collectionRepository.findAllByIdIn(List.of(400010521L))).extracting(Collection::getRecordStatus).containsExactly(RecordStatus.APPROVED);

        currentTenant.setCurrentTenant(edit);
        assertThat(collectionRepository.findAllByIdIn(List.of(400010521L))).extracting(Collection::getRecordStatus).containsExactly(RecordStatus.UNDER_EDIT);
    }

This is most certainly some problem in your Spring related code which only you can debug. Hibernate ORM has plenty of tests that verify it all works and even in your test cases everything seems to work out, so the problem must be on your side obviously.