No need to get EM if no tenant has to be set.
Signed-off-by: Kai Zimmermann <kai.zimmermann@bosch-si.com>
This commit is contained in:
@@ -35,12 +35,11 @@ public class MultiTenantJpaTransactionManager extends JpaTransactionManager {
|
|||||||
protected void doBegin(final Object transaction, final TransactionDefinition definition) {
|
protected void doBegin(final Object transaction, final TransactionDefinition definition) {
|
||||||
super.doBegin(transaction, definition);
|
super.doBegin(transaction, definition);
|
||||||
|
|
||||||
final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager
|
|
||||||
.getResource(getEntityManagerFactory());
|
|
||||||
final EntityManager em = emHolder.getEntityManager();
|
|
||||||
|
|
||||||
final String currentTenant = tenantAware.getCurrentTenant();
|
final String currentTenant = tenantAware.getCurrentTenant();
|
||||||
if (currentTenant != null) {
|
if (currentTenant != null) {
|
||||||
|
final EntityManagerHolder emHolder = (EntityManagerHolder) TransactionSynchronizationManager
|
||||||
|
.getResource(getEntityManagerFactory());
|
||||||
|
final EntityManager em = emHolder.getEntityManager();
|
||||||
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
|
em.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, currentTenant.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user