Sonar Fixes (#2233)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-01-24 15:41:06 +02:00
committed by GitHub
parent 0280d96d2c
commit a61e9cd6ae
66 changed files with 401 additions and 387 deletions

View File

@@ -33,6 +33,8 @@ public class Jpa {
log.info("JPA vendor: {}", JPA_VENDOR);
}
// intentional, if it is a constant the compiler will inline it, we want to be changed with changing the JPA vendor lib
@SuppressWarnings("java:S3400")
public static char nativeQueryParamPrefix() {
return '?';
}

View File

@@ -14,6 +14,7 @@ import java.util.Map;
import javax.sql.DataSource;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.persistence.config.PersistenceUnitProperties;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration;
@@ -33,10 +34,14 @@ import org.springframework.transaction.jta.JtaTransactionManager;
@Configuration
public class JpaConfiguration extends JpaBaseConfiguration {
private final TenantAware tenantAware;
protected JpaConfiguration(
final DataSource dataSource, final JpaProperties properties,
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider) {
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
final TenantAware tenantAware) {
super(dataSource, properties, jtaTransactionManagerProvider);
this.tenantAware = tenantAware;
}
/**
@@ -48,7 +53,7 @@ public class JpaConfiguration extends JpaBaseConfiguration {
@Override
@Bean
public PlatformTransactionManager transactionManager(final ObjectProvider<TransactionManagerCustomizers> transactionManagerCustomizers) {
return new MultiTenantJpaTransactionManager();
return new MultiTenantJpaTransactionManager(tenantAware);
}
@Override

View File

@@ -38,7 +38,6 @@ class MultiTenantJpaTransactionManager extends JpaTransactionManager {
@Serial
private static final long serialVersionUID = 1L;
@Autowired
private transient TenantAware tenantAware;
private static final Class<?> JPA_TARGET;
@@ -53,6 +52,10 @@ class MultiTenantJpaTransactionManager extends JpaTransactionManager {
}
}
MultiTenantJpaTransactionManager(final TenantAware tenantAware) {
this.tenantAware = tenantAware;
}
private static final EntityPropertyChangeListener ENTITY_PROPERTY_CHANGE_LISTENER = new EntityPropertyChangeListener();
@Override