Fix != and =out= for maps in G2 RSQL to Specification (#2426)
+ add initial draft of Standalone RSQL test + provide option to override Hibernate / Eclipselink configuration via standard spring environment properties Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
package org.eclipse.hawkbit.repository.jpa;
|
||||
|
||||
import jakarta.persistence.TypedQuery;
|
||||
import jakarta.persistence.Query;
|
||||
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -18,12 +18,12 @@ import org.eclipse.persistence.jpa.JpaQuery;
|
||||
|
||||
@NoArgsConstructor(access = lombok.AccessLevel.PRIVATE)
|
||||
@Slf4j
|
||||
public class Utils {
|
||||
public class EclipselinkUtils {
|
||||
|
||||
public static String toSql(final TypedQuery<?> typedQuery) {
|
||||
typedQuery.setParameter(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, "DEFAULT");
|
||||
public static String toSql(final Query query) {
|
||||
query.setParameter(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, "DEFAULT");
|
||||
// executes the query - otherwise the SQL string is not generated
|
||||
typedQuery.getResultList();
|
||||
return typedQuery.unwrap(JpaQuery.class).getDatabaseQuery().getSQLString();
|
||||
query.getResultList();
|
||||
return query.unwrap(JpaQuery.class).getDatabaseQuery().getSQLString();
|
||||
}
|
||||
}
|
||||
@@ -14,14 +14,17 @@ import java.util.Map;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import lombok.Data;
|
||||
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;
|
||||
import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
|
||||
import org.springframework.boot.autoconfigure.transaction.TransactionManagerCustomizers;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.orm.jpa.vendor.AbstractJpaVendorAdapter;
|
||||
import org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect;
|
||||
import org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter;
|
||||
@@ -32,16 +35,29 @@ import org.springframework.transaction.jta.JtaTransactionManager;
|
||||
* General EclipseLink configuration for hawkBit's Repository.
|
||||
*/
|
||||
@Configuration
|
||||
@Import(JpaConfiguration.Properties.class)
|
||||
public class JpaConfiguration extends JpaBaseConfiguration {
|
||||
|
||||
@Data
|
||||
@ConfigurationProperties // predix is "/" intentionally
|
||||
protected static class Properties {
|
||||
|
||||
private final Map<String, String> eclipselink = new HashMap<>();
|
||||
}
|
||||
|
||||
private final TenantAware.TenantResolver tenantResolver;
|
||||
// only for testing purposes ddl generation may be enabled
|
||||
private final Map<String, String> eclipselinkProperties;
|
||||
|
||||
|
||||
protected JpaConfiguration(
|
||||
final DataSource dataSource, final JpaProperties properties,
|
||||
final ObjectProvider<JtaTransactionManager> jtaTransactionManagerProvider,
|
||||
final TenantAware.TenantResolver tenantResolver) {
|
||||
final TenantAware.TenantResolver tenantResolver,
|
||||
final Properties eclipselinkProperties) {
|
||||
super(dataSource, properties, jtaTransactionManagerProvider);
|
||||
this.tenantResolver = tenantResolver;
|
||||
this.eclipselinkProperties = eclipselinkProperties.getEclipselink();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,7 +92,7 @@ public class JpaConfiguration extends JpaBaseConfiguration {
|
||||
properties.put(PersistenceUnitProperties.WEAVING, "false");
|
||||
// needed for reports
|
||||
properties.put(PersistenceUnitProperties.ALLOW_NATIVE_SQL_QUERIES, "true");
|
||||
// flyway
|
||||
// by default - none, flyway
|
||||
properties.put(PersistenceUnitProperties.DDL_GENERATION, "none");
|
||||
// Embed into hawkBit logging
|
||||
properties.put(PersistenceUnitProperties.LOGGING_LOGGER, "JavaLogger");
|
||||
@@ -86,6 +102,9 @@ public class JpaConfiguration extends JpaBaseConfiguration {
|
||||
properties.put(PersistenceUnitProperties.BATCH_WRITING, "JDBC");
|
||||
// Batch size
|
||||
properties.put(PersistenceUnitProperties.BATCH_WRITING_SIZE, "500");
|
||||
|
||||
// override with all explicitly configured properties
|
||||
properties.putAll(eclipselinkProperties);
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user