Skip to content

Commit

Permalink
feat: log warning in case of finding spring.jpa properties configuration
Browse files Browse the repository at this point in the history
Related to quarkusio#6192
  • Loading branch information
aureamunoz committed Dec 23, 2019
1 parent a960d85 commit 583e628
Showing 1 changed file with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package io.quarkus.spring.data.deployment;

import static java.util.stream.Collectors.*;

import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.*;

import org.eclipse.microprofile.config.Config;
import org.eclipse.microprofile.config.ConfigProvider;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.CompositeIndex;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
import org.jboss.jandex.Indexer;
import org.jboss.logging.Logger;
import org.springframework.data.domain.Auditable;
import org.springframework.data.domain.Persistable;
import org.springframework.data.jpa.repository.JpaRepository;
Expand All @@ -35,6 +35,8 @@

public class SpringDataJPAProcessor {

private static final Logger LOGGER = Logger.getLogger(SpringDataJPAProcessor.class.getName());

@BuildStep
FeatureBuildItem registerFeature() {
return new FeatureBuildItem(FeatureBuildItem.SPRING_DATA_JPA);
Expand All @@ -53,6 +55,27 @@ void build(CombinedIndexBuildItem index,
BuildProducer<GeneratedBeanBuildItem> generatedBeans,
BuildProducer<AdditionalBeanBuildItem> additionalBeans) {

Config config = ConfigProvider.getConfig();
Optional<String> springJpaConfig = config.getOptionalValue("spring.jpa.show-sql", String.class);
Map<String, String> springJpaPropertiesMap = new HashMap<>();
springJpaPropertiesMap.put("spring.jpa.show-sql", "quarkus.hibernate-orm.log.sql");
springJpaPropertiesMap.put("spring.jpa.properties.hibernate.dialect ", "quarkus.hibernate-orm.dialect");
springJpaPropertiesMap.put("spring.jpa.properties.hibernate.dialect.storage_engine",
"quarkus.hibernate-orm.dialect.storage-engine");
springJpaPropertiesMap.put("spring.jpa.generate-ddl", "quarkus.hibernate-orm.database.generation");

Iterable<String> iterablePropertyNames = config.getPropertyNames();
List<String> propertyNames = new ArrayList<String>();
iterablePropertyNames.forEach(propertyNames::add);
List<String> springProperties = propertyNames.stream().filter(s -> s.matches("spring.jpa.*")).collect(toList());
if (!springProperties.isEmpty()) {
for (String springProperty : springProperties) {
LOGGER.warn("Quarkus does not support the " + springProperty
+ " you may try to use the quarkus equivalent : " + springJpaPropertiesMap.get(springProperty));
}

}

IndexView indexIndex = index.getIndex();
List<ClassInfo> interfacesExtendingCrudRepository = getAllInterfacesExtending(DotNames.SUPPORTED_REPOSITORIES,
indexIndex);
Expand Down

0 comments on commit 583e628

Please sign in to comment.