From 6716b841dc630c0b8f1069e415812f9ab0d91acb Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 1 Dec 2020 20:10:21 +0000 Subject: [PATCH 1/5] Resolve javadoc validation problem --- .../reactive/deployment/HibernateReactiveProcessor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java b/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java index 0264d2106629a..e4e5781ac6969 100644 --- a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java +++ b/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java @@ -169,7 +169,7 @@ PersistenceProviderSetUpBuildItem setUpPersistenceProviderAndWaitForVertxPool( /** * This is mostly copied from - * {@link io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#handleHibernateORMWithNoPersistenceXml} + * io.quarkus.hibernate.orm.deployment.HibernateOrmProcessor#handleHibernateORMWithNoPersistenceXml * Key differences are: * - Always produces a persistence unit descriptor, since we assume there always 1 reactive persistence unit * - Any JDBC-only configuration settings are removed From cf3f333b6ccd104696964bb338d2ab32e8b6b132 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 1 Dec 2020 16:02:21 +0000 Subject: [PATCH 2/5] Upgrade to Hibernate ORM 5.4.25.Final --- bom/application/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 1d2efe61e19e2..1c041f9de997e 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -89,7 +89,7 @@ 3.9 1.14 1.3.4 - 5.4.24.Final + 5.4.25.Final 1.0.0.Alpha11 6.1.6.Final 6.0.0.CR2 From 801ade7c567f589d531bab5f381f178a31b72dcb Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 1 Dec 2020 20:01:48 +0000 Subject: [PATCH 3/5] Have the Envers extension publish a Capability --- .../src/main/java/io/quarkus/deployment/Capability.java | 1 + .../envers/deployment/HibernateEnversProcessor.java | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java index db7b2b4bd5cde..d190ad8c571e3 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/Capability.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/Capability.java @@ -51,6 +51,7 @@ public enum Capability { CONTAINER_IMAGE_S2I, CONTAINER_IMAGE_OPENSHIFT, HIBERNATE_ORM, + HIBERNATE_ENVERS, HIBERNATE_REACTIVE, HIBERNATE_VALIDATOR, /** diff --git a/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java b/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java index 615f71a77f966..9604afb0b264e 100644 --- a/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java +++ b/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java @@ -3,11 +3,13 @@ import java.util.Arrays; import java.util.List; +import io.quarkus.deployment.Capability; import io.quarkus.deployment.Feature; import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; +import io.quarkus.deployment.builditem.CapabilityBuildItem; import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.logging.LogCleanupFilterBuildItem; @@ -22,6 +24,11 @@ FeatureBuildItem feature() { return new FeatureBuildItem(Feature.HIBERNATE_ENVERS); } + @BuildStep + CapabilityBuildItem capability() { + return new CapabilityBuildItem(Capability.HIBERNATE_ENVERS); + } + @BuildStep List addJpaModelClasses() { return Arrays.asList( From 8560764f9686c8d2d94b9e912874a8a5ca4107b3 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 1 Dec 2020 20:09:49 +0000 Subject: [PATCH 4/5] Propagate a flag to signal the presence of Envers to the PersistenceUnitDescriptorBuildItem --- .../orm/deployment/HibernateOrmProcessor.java | 9 +++++-- .../PersistenceUnitDescriptorBuildItem.java | 9 ++++--- .../runtime/boot/FastBootMetadataBuilder.java | 2 ++ .../QuarkusPersistenceUnitDefinition.java | 25 ++++++++++++++++--- .../HibernateReactiveProcessor.java | 6 ++++- 5 files changed, 42 insertions(+), 9 deletions(-) diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java index d1771d9015436..48026f5ee5bf9 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java @@ -290,6 +290,8 @@ public void configurationDescriptorBuilding( return; } + final boolean enversIsPresent = capabilities.isPresent(Capability.HIBERNATE_ENVERS); + // First produce the PUs having a persistence.xml: these are not reactive, as we don't allow using a persistence.xml for them. for (PersistenceXmlDescriptorBuildItem persistenceXmlDescriptorBuildItem : persistenceXmlDescriptors) { persistenceUnitDescriptors @@ -299,7 +301,8 @@ public void configurationDescriptorBuilding( .getProperties().getProperty(AvailableSettings.MULTI_TENANT))), null, false, - true)); + true, + enversIsPresent)); } if (impliedPU.shouldGenerateImpliedBlockingPersistenceUnit()) { @@ -882,11 +885,13 @@ private static void producePersistenceUnitDescriptorFromConfig( storageEngineCollector.add(persistenceUnitConfig.dialect.storageEngine.get()); } + final boolean isEnversPresent = capabilities.isPresent(Capability.HIBERNATE_ENVERS); + persistenceUnitDescriptors.produce( new PersistenceUnitDescriptorBuildItem(descriptor, dataSource, getMultiTenancyStrategy(persistenceUnitConfig.multitenant), persistenceUnitConfig.multitenantSchemaDatasource.orElse(null), - false, false)); + false, false, isEnversPresent)); } public static Optional guessDialect(String resolvedDbKind) { diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/PersistenceUnitDescriptorBuildItem.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/PersistenceUnitDescriptorBuildItem.java index 53873c9eb8298..714cae62b24a3 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/PersistenceUnitDescriptorBuildItem.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/PersistenceUnitDescriptorBuildItem.java @@ -18,6 +18,7 @@ public final class PersistenceUnitDescriptorBuildItem extends MultiBuildItem { private final ParsedPersistenceXmlDescriptor descriptor; + private final boolean enversIsPresent; private final String dataSource; private final MultiTenancyStrategy multiTenancyStrategy; private final String multiTenancySchemaDataSource; @@ -25,8 +26,9 @@ public final class PersistenceUnitDescriptorBuildItem extends MultiBuildItem { private final boolean fromPersistenceXml; public PersistenceUnitDescriptorBuildItem(ParsedPersistenceXmlDescriptor descriptor, boolean isReactive, - boolean fromPersistenceXml) { + boolean fromPersistenceXml, boolean enversIsPresent) { this.descriptor = descriptor; + this.enversIsPresent = enversIsPresent; this.dataSource = DataSourceUtil.DEFAULT_DATASOURCE_NAME; this.multiTenancyStrategy = MultiTenancyStrategy.NONE; this.multiTenancySchemaDataSource = null; @@ -36,9 +38,10 @@ public PersistenceUnitDescriptorBuildItem(ParsedPersistenceXmlDescriptor descrip public PersistenceUnitDescriptorBuildItem(ParsedPersistenceXmlDescriptor descriptor, String dataSource, MultiTenancyStrategy multiTenancyStrategy, String multiTenancySchemaDataSource, boolean isReactive, - boolean fromPersistenceXml) { + boolean fromPersistenceXml, boolean enversIsPresent) { this.descriptor = descriptor; this.dataSource = dataSource; + this.enversIsPresent = enversIsPresent; this.multiTenancyStrategy = multiTenancyStrategy; this.multiTenancySchemaDataSource = multiTenancySchemaDataSource; this.isReactive = isReactive; @@ -71,6 +74,6 @@ public String getMultiTenancySchemaDataSource() { public QuarkusPersistenceUnitDefinition asOutputPersistenceUnitDefinition() { return new QuarkusPersistenceUnitDefinition(descriptor, dataSource, multiTenancyStrategy, isReactive, - fromPersistenceXml); + fromPersistenceXml, enversIsPresent); } } diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java index dec3652f37c4d..56074ba7c1cfb 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java @@ -100,11 +100,13 @@ public class FastBootMetadataBuilder { private final MultiTenancyStrategy multiTenancyStrategy; private final boolean isReactive; private final boolean fromPersistenceXml; + private final boolean isEnversPresent; @SuppressWarnings("unchecked") public FastBootMetadataBuilder(final QuarkusPersistenceUnitDefinition puDefinition, Scanner scanner, Collection> additionalIntegrators, PreGeneratedProxies preGeneratedProxies) { this.persistenceUnit = puDefinition.getActualHibernateDescriptor(); + this.isEnversPresent = puDefinition.isEnversPresent(); this.dataSource = puDefinition.getDataSource(); this.isReactive = puDefinition.isReactive(); this.fromPersistenceXml = puDefinition.isFromPersistenceXml(); diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/QuarkusPersistenceUnitDefinition.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/QuarkusPersistenceUnitDefinition.java index 0745d3e457b97..10c0cb447c03d 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/QuarkusPersistenceUnitDefinition.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/QuarkusPersistenceUnitDefinition.java @@ -24,9 +24,11 @@ public final class QuarkusPersistenceUnitDefinition { private final MultiTenancyStrategy multitenancyStrategy; private final boolean isReactive; private final boolean fromPersistenceXml; + private final boolean enversPresent; public QuarkusPersistenceUnitDefinition(PersistenceUnitDescriptor persistenceUnitDescriptor, String dataSource, - MultiTenancyStrategy multitenancyStrategy, boolean isReactive, boolean fromPersistenceXml) { + MultiTenancyStrategy multitenancyStrategy, boolean isReactive, boolean fromPersistenceXml, + boolean enversPresent) { Objects.requireNonNull(persistenceUnitDescriptor); Objects.requireNonNull(multitenancyStrategy); this.actualHibernateDescriptor = LightPersistenceXmlDescriptor.validateAndReadFrom(persistenceUnitDescriptor); @@ -34,6 +36,7 @@ public QuarkusPersistenceUnitDefinition(PersistenceUnitDescriptor persistenceUni this.multitenancyStrategy = multitenancyStrategy; this.isReactive = isReactive; this.fromPersistenceXml = fromPersistenceXml; + this.enversPresent = enversPresent; } /** @@ -43,7 +46,8 @@ private QuarkusPersistenceUnitDefinition(LightPersistenceXmlDescriptor persisten String dataSource, MultiTenancyStrategy multitenancyStrategy, boolean isReactive, - boolean fromPersistenceXml) { + boolean fromPersistenceXml, + boolean enversPresent) { Objects.requireNonNull(persistenceUnitDescriptor); Objects.requireNonNull(dataSource); Objects.requireNonNull(multitenancyStrategy); @@ -52,6 +56,7 @@ private QuarkusPersistenceUnitDefinition(LightPersistenceXmlDescriptor persisten this.multitenancyStrategy = multitenancyStrategy; this.isReactive = isReactive; this.fromPersistenceXml = fromPersistenceXml; + this.enversPresent = enversPresent; } public PersistenceUnitDescriptor getActualHibernateDescriptor() { @@ -79,6 +84,10 @@ public boolean isFromPersistenceXml() { return fromPersistenceXml; } + public boolean isEnversPresent() { + return enversPresent; + } + /** * This includes the state of both the QuarkusPersistenceUnitDefinition * and its more complex field of type LightPersistenceXmlDescriptor @@ -97,6 +106,7 @@ public static class Serialized { private SharedCacheMode puSharedCachemode; private List puManagedClassNames; private Properties puProperties; + private boolean enversIsPresent; //All standard getters and setters generated by IDE: @@ -195,6 +205,14 @@ public Properties getPuProperties() { public void setPuProperties(Properties puProperties) { this.puProperties = puProperties; } + + public boolean isEnversIsPresent() { + return enversIsPresent; + } + + public void setEnversIsPresent(boolean enversIsPresent) { + this.enversIsPresent = enversIsPresent; + } } public static final class Substitution implements ObjectSubstitution { @@ -216,6 +234,7 @@ public Serialized serialize(final QuarkusPersistenceUnitDefinition obj) { s.setMultitenancyStrategy(obj.getMultitenancyStrategy()); s.setReactive(obj.isReactive); s.setFromPersistenceXml(obj.isFromPersistenceXml()); + s.setEnversIsPresent(obj.isEnversPresent()); return s; } @@ -226,7 +245,7 @@ public QuarkusPersistenceUnitDefinition deserialize(Serialized obj) { obj.puValidationMode, obj.puSharedCachemode, obj.puManagedClassNames, obj.puProperties); return new QuarkusPersistenceUnitDefinition(xmlDescriptor, obj.getDataSource(), obj.getMultitenancyStrategy(), - obj.isReactive(), obj.isFromPersistenceXml()); + obj.isReactive(), obj.isFromPersistenceXml(), obj.isEnversIsPresent()); } } diff --git a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java b/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java index e4e5781ac6969..f273ca7cec2a5 100644 --- a/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java +++ b/extensions/hibernate-reactive/deployment/src/main/java/io/quarkus/hibernate/reactive/deployment/HibernateReactiveProcessor.java @@ -146,7 +146,11 @@ public void buildReactivePersistenceUnit( dbKind, applicationArchivesBuildItem, launchMode.getLaunchMode(), systemProperties, nativeImageResources, hotDeploymentWatchedFiles); - persistenceUnitDescriptors.produce(new PersistenceUnitDescriptorBuildItem(reactivePU, true, false)); + //Some constant arguments to the following method: + // - this is Reactive + // - we don't support starting Hibernate Reactive from a persistence.xml + // - we don't support Hibernate Envers with Hibernate Reactive + persistenceUnitDescriptors.produce(new PersistenceUnitDescriptorBuildItem(reactivePU, true, false, false)); } } From 66b8bd6700f777dda9bf90272f87ad0d4ccc992e Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Tue, 1 Dec 2020 20:25:51 +0000 Subject: [PATCH 5/5] Only allow activating XML_MAPPING_ENABLED if Hibernate Envers is present --- .../orm/runtime/boot/FastBootMetadataBuilder.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java index 56074ba7c1cfb..07ad4515b94e1 100644 --- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java +++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java @@ -250,10 +250,18 @@ private MergedSettings mergeSettings(PersistenceUnitDescriptor persistenceUnit) } cfg.put(WRAP_RESULT_SETS, "false"); - if (readBooleanConfigurationValue(cfg, XML_MAPPING_ENABLED)) { - LOG.warn("XML mapping is not supported. Setting " + XML_MAPPING_ENABLED + " to false."); + //Hibernate Envers requires XML_MAPPING_ENABLED to be activated, but we don't want to enable this for any other use: + if (isEnversPresent) { + if (readBooleanConfigurationValue(cfg, XML_MAPPING_ENABLED)) { + LOG.warn( + "XML mapping is not supported. It will be partially activated to allow compatibility with Hibernate Envers, but this support is temporary"); + } + } else { + if (readBooleanConfigurationValue(cfg, XML_MAPPING_ENABLED)) { + LOG.warn("XML mapping is not supported. Setting " + XML_MAPPING_ENABLED + " to false."); + } + cfg.put(XML_MAPPING_ENABLED, "false"); } - cfg.put(XML_MAPPING_ENABLED, "false"); // Note: this one is not a boolean, just having the property enables it if (cfg.containsKey(JACC_ENABLED)) {