io.smilego.tenant.persistence.hibernate.CurrentTenantIdentifierResolverImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multi-tenant-spring-boot-starter Show documentation
Show all versions of multi-tenant-spring-boot-starter Show documentation
A application used as an example on how to set up pushing
its components to the Central Repository.
package io.smilego.tenant.persistence.hibernate;
import io.smilego.tenant.TenantContext;
import org.hibernate.context.spi.CurrentTenantIdentifierResolver;
import org.springframework.util.StringUtils;
public class CurrentTenantIdentifierResolverImpl implements CurrentTenantIdentifierResolver {
@Override
public String resolveCurrentTenantIdentifier() {
String tenantId = TenantContext.getTenantId();
if (!StringUtils.isEmpty(tenantId)) {
return tenantId;
} else {
// Allow bootstrapping the EntityManagerFactory, in which case no tenant is needed
return "BOOTSTRAP";
}
}
@Override
public boolean validateExistingCurrentSessions() {
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy