Multitenancy breaks after 6.2 breaks upgrade

I have solved it. It was a red herring. While debugging I had introduced the @Container annotation in my PostgresIntegrationTest interface that all Testcontainer tests implement. This annotation closes the Testcontainer after the first test runs. You cannot use @Container or @ServiceConnection - you have to use @DynamicPropertyRegistry and call container.start() within the method

Another issue was that in MultiTenantConnectionProvider.getConnection I had put the connection inside a try block’s parenthesis, which meant the connection would get closed automatically. You have to leave it open and allow Hibernate to manage it

1 Like