Skip to content

Commit

Permalink
Upgrade to Hibernate ORM 7.0.0.Alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Jun 21, 2024
1 parent 37e4e01 commit a07509e
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 420 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<jakarta.json-api.version>2.1.3</jakarta.json-api.version>
<jakarta.json.bind-api.version>3.0.1</jakarta.json.bind-api.version>
<jakarta.mail.version>2.0.1</jakarta.mail.version>
<jakarta.persistence-api.version>3.2.0-M2</jakarta.persistence-api.version>
<jakarta.persistence-api.version>3.2.0</jakarta.persistence-api.version>
<jakarta.resource-api.version>2.1.0</jakarta.resource-api.version>
<jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
<jakarta.transaction-api.version>2.0.1</jakarta.transaction-api.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ private static DotName createConstant(String fqcn) {
public static final DotName XML_FORMAT = createConstant("io.quarkus.hibernate.orm.XmlFormat");

public static final List<DotName> GENERATORS = List.of(
createConstant("org.hibernate.generator.Assigned"),
createConstant("org.hibernate.generator.internal.CurrentTimestampGeneration"),
createConstant("org.hibernate.generator.internal.GeneratedAlwaysGeneration"),
createConstant("org.hibernate.generator.internal.GeneratedGeneration"),
Expand All @@ -79,8 +80,6 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.id.enhanced.SequenceStyleGenerator"),
createConstant("org.hibernate.id.enhanced.TableGenerator"),
createConstant("org.hibernate.id.uuid.UuidGenerator"),
createConstant("org.hibernate.tuple.CreationTimestampGeneration"),
createConstant("org.hibernate.tuple.UpdateTimestampGeneration"),
createConstant("org.hibernate.tuple.VmValueGeneration"));

public static final List<DotName> PACKAGE_ANNOTATIONS = List.of(
Expand Down Expand Up @@ -368,6 +367,7 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.annotations.Parent"),
createConstant("org.hibernate.annotations.PartitionKey"),
createConstant("org.hibernate.annotations.Polymorphism"),
createConstant("org.hibernate.annotations.PropertyRef"),
createConstant("org.hibernate.annotations.Proxy"),
createConstant("org.hibernate.annotations.QueryCacheLayout"),
createConstant("org.hibernate.annotations.RowId"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.jpa.boot.spi.JpaSettings;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;
import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.jpa.boot.spi.PersistenceXmlParser;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget.Kind;
import org.jboss.jandex.AnnotationValue;
Expand Down Expand Up @@ -130,6 +130,7 @@
import io.quarkus.hibernate.orm.runtime.proxies.PreGeneratedProxies;
import io.quarkus.hibernate.orm.runtime.recording.RecordedConfig;
import io.quarkus.hibernate.orm.runtime.schema.SchemaManagementIntegrator;
import io.quarkus.hibernate.orm.runtime.service.FlatClassLoaderService;
import io.quarkus.hibernate.orm.runtime.tenant.DataSourceTenantConnectionResolver;
import io.quarkus.hibernate.orm.runtime.tenant.TenantConnectionResolver;
import io.quarkus.panache.common.deployment.HibernateEnhancersRegisteredBuildItem;
Expand Down Expand Up @@ -256,8 +257,12 @@ List<HotDeploymentWatchedFileBuildItem> hotDeploymentWatchedFiles(HibernateOrmCo
public void parsePersistenceXmlDescriptors(HibernateOrmConfig config,
BuildProducer<PersistenceXmlDescriptorBuildItem> persistenceXmlDescriptorBuildItemBuildProducer) {
if (!shouldIgnorePersistenceXmlResources(config)) {
var explicitDescriptors = QuarkusPersistenceXmlParser.locatePersistenceUnits();
for (var desc : explicitDescriptors) {
var parser = PersistenceXmlParser.create(Map.of(), null, FlatClassLoaderService.INSTANCE);
var urls = parser.getClassLoaderService().locateResources("META-INF/persistence.xml");
if (urls.isEmpty()) {
return;
}
for (var desc : parser.parse(urls).values()) {
persistenceXmlDescriptorBuildItemBuildProducer.produce(new PersistenceXmlDescriptorBuildItem(desc));
}
}
Expand Down Expand Up @@ -973,7 +978,6 @@ private static void producePersistenceUnitDescriptorFromConfig(
if (batchSize > 0) {
descriptor.getProperties().setProperty(AvailableSettings.DEFAULT_BATCH_FETCH_SIZE,
Integer.toString(batchSize));
descriptor.getProperties().setProperty(AvailableSettings.BATCH_FETCH_STYLE, BatchFetchStyle.PADDED.toString());
}

if (persistenceUnitConfig.fetch().maxDepth().isPresent()) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,6 @@ public void setId(EmbeddableIdWithAnnotation id) {
}
}

@MappedSuperclass
public interface Identifiable {
Object getId();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public void fetch(Object association) {
delegate.get().fetch(association);
}

@Override
public Object getIdentifier(Object entity) {
return delegate.get().getIdentifier(entity);
}

@Override
public String getTenantIdentifier() {
return delegate.get().getTenantIdentifier();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.boot.spi.MetadataBuilderContributor;
import org.hibernate.boot.spi.MetadataBuilderImplementor;
import org.hibernate.cache.internal.CollectionCacheInvalidator;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.EntityManagerMessageLogger;
import org.hibernate.internal.util.StringHelper;
Expand All @@ -60,7 +58,6 @@
import org.hibernate.jpa.boot.spi.TypeContributorList;
import org.hibernate.jpa.internal.util.LogHelper;
import org.hibernate.jpa.internal.util.PersistenceUnitTransactionTypeHelper;
import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider;
import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode;
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
Expand All @@ -80,7 +77,6 @@
import io.quarkus.hibernate.orm.runtime.recording.PrevalidatedQuarkusMetadata;
import io.quarkus.hibernate.orm.runtime.recording.RecordableBootstrap;
import io.quarkus.hibernate.orm.runtime.recording.RecordedState;
import io.quarkus.hibernate.orm.runtime.service.QuarkusMutableIdentifierGeneratorFactory;
import io.quarkus.hibernate.orm.runtime.service.QuarkusStaticInitDialectFactory;
import io.quarkus.hibernate.orm.runtime.tenant.HibernateMultiTenantConnectionProvider;

Expand Down Expand Up @@ -144,7 +140,6 @@ public FastBootMetadataBuilder(final QuarkusPersistenceUnitDefinition puDefiniti
ssrBuilder.applySettings(buildTimeSettings.getAllSettings());

this.standardServiceRegistry = ssrBuilder.build();
registerIdentifierGenerators(standardServiceRegistry);

this.providedServices = ssrBuilder.getProvidedServices();

Expand Down Expand Up @@ -452,6 +447,7 @@ private PrevalidatedQuarkusMetadata trimBootstrapMetadata(MetadataImpl fullMeta)
fullMeta.getEntityBindingMap(),
fullMeta.getComposites(),
fullMeta.getGenericComponentsMap(),
fullMeta.getEmbeddableDiscriminatorTypesMap(),
fullMeta.getMappedSuperclassMap(),
fullMeta.getCollectionBindingMap(),
fullMeta.getTypeDefinitionMap(),
Expand Down Expand Up @@ -614,32 +610,6 @@ private static void applyTransactionProperties(PersistenceUnitDescriptor persist
}
}

private void registerIdentifierGenerators(StandardServiceRegistry ssr) {
final StrategySelector strategySelector = ssr.getService(StrategySelector.class);

// apply id generators
final Object idGeneratorStrategyProviderSetting = buildTimeSettings
.get(AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER);
if (idGeneratorStrategyProviderSetting != null) {
final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = strategySelector
.resolveStrategy(IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting);
final IdentifierGeneratorFactory identifierGeneratorFactory = ssr
.getService(IdentifierGeneratorFactory.class);
if (identifierGeneratorFactory == null) {
throw persistenceException("Application requested custom identifier generator strategies, "
+ "but the MutableIdentifierGeneratorFactory could not be found");
}
if (!(identifierGeneratorFactory instanceof QuarkusMutableIdentifierGeneratorFactory)) {
throw persistenceException(
"Unexpected implementation of IdentifierGeneratorFactory: do not override core components");
}
final QuarkusMutableIdentifierGeneratorFactory qIdGenerator = (QuarkusMutableIdentifierGeneratorFactory) identifierGeneratorFactory;
for (Map.Entry<String, Class<?>> entry : idGeneratorStrategyProvider.getStrategies().entrySet()) {
qIdGenerator.register(entry.getKey(), entry.getValue());
}
}
}

/**
* Greatly simplified copy of
* org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl#populate(org.hibernate.boot.MetadataBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.Set;
import java.util.UUID;
import java.util.function.Consumer;
import java.util.function.Supplier;

import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
Expand All @@ -30,6 +31,7 @@
import org.hibernate.mapping.MappedSuperclass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
import org.hibernate.metamodel.mapping.DiscriminatorType;
import org.hibernate.query.named.NamedObjectRepository;
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
Expand Down Expand Up @@ -294,6 +296,12 @@ public Component getGenericComponent(Class<?> componentClass) {
return metadata.getGenericComponent(componentClass);
}

@Override
public DiscriminatorType<?> resolveEmbeddableDiscriminatorType(Class<?> embeddableClass,
Supplier<DiscriminatorType<?>> supplier) {
return metadata.resolveEmbeddableDiscriminatorType(embeddableClass, supplier);
}

public Map<String, PersistentClass> getEntityBindingMap() {
return metadata.getEntityBindingMap();
}
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit a07509e

Please sign in to comment.