Skip to content

Commit

Permalink
Merge pull request #13607 from Sanne/ORM5.4.25
Browse files Browse the repository at this point in the history
Upgrade to Hibernate ORM 5.4.25.Final
  • Loading branch information
gsmet authored Dec 3, 2020
2 parents 643c66a + 66b8bd6 commit c788df9
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
<commons-lang3.version>3.9</commons-lang3.version>
<commons-codec.version>1.14</commons-codec.version>
<classmate.version>1.3.4</classmate.version>
<hibernate-orm.version>5.4.24.Final</hibernate-orm.version>
<hibernate-orm.version>5.4.25.Final</hibernate-orm.version>
<hibernate-reactive.version>1.0.0.Alpha11</hibernate-reactive.version>
<hibernate-validator.version>6.1.6.Final</hibernate-validator.version>
<hibernate-search.version>6.0.0.CR2</hibernate-search.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public enum Capability {
CONTAINER_IMAGE_S2I,
CONTAINER_IMAGE_OPENSHIFT,
HIBERNATE_ORM,
HIBERNATE_ENVERS,
HIBERNATE_REACTIVE,
HIBERNATE_VALIDATOR,
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,6 +24,11 @@ FeatureBuildItem feature() {
return new FeatureBuildItem(Feature.HIBERNATE_ENVERS);
}

@BuildStep
CapabilityBuildItem capability() {
return new CapabilityBuildItem(Capability.HIBERNATE_ENVERS);
}

@BuildStep
List<AdditionalJpaModelBuildItem> addJpaModelClasses() {
return Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -299,7 +301,8 @@ public void configurationDescriptorBuilding(
.getProperties().getProperty(AvailableSettings.MULTI_TENANT))),
null,
false,
true));
true,
enversIsPresent));
}

if (impliedPU.shouldGenerateImpliedBlockingPersistenceUnit()) {
Expand Down Expand Up @@ -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<String> guessDialect(String resolvedDbKind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@
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;
private final boolean isReactive;
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;
Expand All @@ -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;
Expand Down Expand Up @@ -71,6 +74,6 @@ public String getMultiTenancySchemaDataSource() {

public QuarkusPersistenceUnitDefinition asOutputPersistenceUnitDefinition() {
return new QuarkusPersistenceUnitDefinition(descriptor, dataSource, multiTenancyStrategy, isReactive,
fromPersistenceXml);
fromPersistenceXml, enversIsPresent);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Class<? extends Integrator>> additionalIntegrators, PreGeneratedProxies preGeneratedProxies) {
this.persistenceUnit = puDefinition.getActualHibernateDescriptor();
this.isEnversPresent = puDefinition.isEnversPresent();
this.dataSource = puDefinition.getDataSource();
this.isReactive = puDefinition.isReactive();
this.fromPersistenceXml = puDefinition.isFromPersistenceXml();
Expand Down Expand Up @@ -248,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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,19 @@ 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);
this.dataSource = dataSource;
this.multitenancyStrategy = multitenancyStrategy;
this.isReactive = isReactive;
this.fromPersistenceXml = fromPersistenceXml;
this.enversPresent = enversPresent;
}

/**
Expand All @@ -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);
Expand All @@ -52,6 +56,7 @@ private QuarkusPersistenceUnitDefinition(LightPersistenceXmlDescriptor persisten
this.multitenancyStrategy = multitenancyStrategy;
this.isReactive = isReactive;
this.fromPersistenceXml = fromPersistenceXml;
this.enversPresent = enversPresent;
}

public PersistenceUnitDescriptor getActualHibernateDescriptor() {
Expand Down Expand Up @@ -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
Expand All @@ -97,6 +106,7 @@ public static class Serialized {
private SharedCacheMode puSharedCachemode;
private List<String> puManagedClassNames;
private Properties puProperties;
private boolean enversIsPresent;

//All standard getters and setters generated by IDE:

Expand Down Expand Up @@ -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<QuarkusPersistenceUnitDefinition, Serialized> {
Expand All @@ -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;
}

Expand All @@ -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());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

}
Expand All @@ -169,7 +173,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
Expand Down

0 comments on commit c788df9

Please sign in to comment.