From 056469262def9af37c861c9b33c9da646448f345 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Sat, 23 Nov 2019 08:51:37 -0600 Subject: [PATCH] HHH-13081 - Pass BootstrapContext to Integrator#integrate; HHH-11990 - Remove LogicalConnectionImplementor#makeShareableCopy 6.0 Alpha3 prep --- changelog.txt | 28 +++++++++++++++++ gradle/base-information.gradle | 2 +- .../hibernate/integrator/spi/Integrator.java | 30 +++++++++++++++++-- .../internal/SessionFactoryImpl.java | 15 ++++++---- .../LogicalConnectionManagedImpl.java | 9 ------ .../LogicalConnectionProvidedImpl.java | 8 ----- .../spi/LogicalConnectionImplementor.java | 9 +----- 7 files changed, 66 insertions(+), 35 deletions(-) diff --git a/changelog.txt b/changelog.txt index 7245e0a971..c1c2bced20 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,34 @@ Hibernate 5 Changelog Note: Please refer to JIRA to learn more about each issue. +Changes in 6.0.0.Alpha1 (November 23, 2019) +------------------------------------------------------------------------------------------------------------------------ + +https://hibernate.atlassian.net/projects/HHH/versions/31768/ + +** Sub-task + * [HHH-13714] - HQL/Criteria UPDATE support + * [HHH-13715] - HQL/Criteria DELETE support + +** New Feature + * [HHH-11474] - Implement support for LIMIT and OFFSET clause + +** Task + * [HHH-13395] - Update Envers to use the new Integrator signature. + * [HHH-13725] - Implement ToOne Associations support + * [HHH-13732] - Implement OneToOne support + +** Improvement + * [HHH-11828] - Adjust EntityMode, Tuplizer and friends to the 6.0 metamodel (Navigable et.al.) contracts + * [HHH-13081] - Pass BootstrapContext to Integrator#integrate + * [HHH-13224] - Look at removing references to SessionFactory from various components + +** Remove Feature + * [HHH-10071] - Remove support for "collection properties" in HQL + * [HHH-11990] - Remove LogicalConnectionImplementor#makeShareableCopy + + + Changes in 5.4.9.Final (November 14, 2019) ------------------------------------------------------------------------------------------------------------------------ diff --git a/gradle/base-information.gradle b/gradle/base-information.gradle index d75e7908b5..0f22708aaa 100644 --- a/gradle/base-information.gradle +++ b/gradle/base-information.gradle @@ -8,7 +8,7 @@ apply plugin: 'base' ext { - ormVersion = new HibernateVersion( '6.0.0-SNAPSHOT', project ) + ormVersion = new HibernateVersion( '6.0.0.Alpha3', project ) baselineJavaVersion = '1.8' jpaVersion = new JpaVersion('2.2') } diff --git a/hibernate-core/src/main/java/org/hibernate/integrator/spi/Integrator.java b/hibernate-core/src/main/java/org/hibernate/integrator/spi/Integrator.java index dca9f06a48..1b3f75b0cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/integrator/spi/Integrator.java +++ b/hibernate-core/src/main/java/org/hibernate/integrator/spi/Integrator.java @@ -6,7 +6,9 @@ */ package org.hibernate.integrator.spi; +import org.hibernate.Incubating; import org.hibernate.boot.Metadata; +import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.service.spi.SessionFactoryServiceRegistry; @@ -27,11 +29,33 @@ public interface Integrator { * @param metadata The "compiled" representation of the mapping information * @param sessionFactory The session factory being created * @param serviceRegistry The session factory's service registry + * @deprecated (since 6.0) - use */ - public void integrate( + @Deprecated + default void integrate( Metadata metadata, SessionFactoryImplementor sessionFactory, - SessionFactoryServiceRegistry serviceRegistry); + SessionFactoryServiceRegistry serviceRegistry) { + throw new UnsupportedOperationException( "Call to un-implemented deprecated legacy `Integrator#integrate` overload form" ); + } + + /** + * Perform integration. + * + * @param metadata The fully initialized boot-time mapping model + * @param bootstrapContext The context for bootstrapping of the SessionFactory + * @param sessionFactory The SessionFactory being created + * + * todo (6.0) : why pass the `serviceRegistry`? Why not just grab it from the SessionFactory? + */ + @Incubating + default void integrate( + Metadata metadata, + BootstrapContext bootstrapContext, + SessionFactoryImplementor sessionFactory) { + // simply call the legacy one, keeping implementors bytecode compatible. + integrate( metadata, sessionFactory, (SessionFactoryServiceRegistry) sessionFactory.getServiceRegistry() ); + } /** * Tongue-in-cheek name for a shutdown callback. @@ -39,6 +63,6 @@ public interface Integrator { * @param sessionFactory The session factory being closed. * @param serviceRegistry That session factory's service registry */ - public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry); + void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry); } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java index db02d9b488..2884c4e0d7 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionFactoryImpl.java @@ -11,7 +11,6 @@ import java.io.InvalidObjectException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.sql.Connection; -import java.sql.SQLException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -32,7 +31,6 @@ import javax.persistence.PersistenceException; import javax.persistence.PersistenceUnitUtil; import javax.persistence.Query; import javax.persistence.SynchronizationType; -import javax.persistence.spi.PersistenceUnitTransactionType; import org.hibernate.ConnectionAcquisitionMode; import org.hibernate.ConnectionReleaseMode; @@ -52,6 +50,8 @@ import org.hibernate.StatelessSessionBuilder; import org.hibernate.boot.cfgxml.spi.CfgXmlAccessService; import org.hibernate.boot.cfgxml.spi.LoadedConfig; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; +import org.hibernate.boot.spi.BootstrapContext; +import org.hibernate.boot.spi.MetadataBuildingContext; import org.hibernate.boot.spi.MetadataImplementor; import org.hibernate.boot.spi.SessionFactoryOptions; import org.hibernate.cache.cfg.internal.DomainDataRegionConfigImpl; @@ -79,7 +79,6 @@ import org.hibernate.engine.profile.Fetch; import org.hibernate.engine.profile.FetchProfile; import org.hibernate.engine.spi.FilterDefinition; import org.hibernate.engine.spi.SessionBuilderImplementor; -import org.hibernate.engine.spi.SessionEventListenerManager; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionOwner; import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform; @@ -203,6 +202,10 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { SessionFactoryOptions options) { LOG.debug( "Building session factory" ); + final TypeConfiguration typeConfiguration = bootMetamodel.getTypeConfiguration(); + final MetadataBuildingContext bootModelBuildingContext = typeConfiguration.getMetadataBuildingContext(); + final BootstrapContext bootstrapContext = bootModelBuildingContext.getBootstrapContext(); + this.sessionFactoryOptions = options; this.settings = new Settings( options, bootMetamodel ); @@ -275,7 +278,7 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { this.observer.addObserver( integratorObserver ); try { for ( Integrator integrator : serviceRegistry.getService( IntegratorService.class ).getIntegrators() ) { - integrator.integrate( bootMetamodel, this, this.serviceRegistry ); + integrator.integrate( bootMetamodel, bootstrapContext, this ); integratorObserver.integrators.add( integrator ); } //Generators: @@ -295,10 +298,10 @@ public final class SessionFactoryImpl implements SessionFactoryImplementor { primeSecondLevelCacheRegions( bootMetamodel ); - this.metamodel = bootMetamodel.getTypeConfiguration().scope( this ); + this.metamodel = typeConfiguration.scope( this ); ( (DomainMetamodelImpl) metamodel ).finishInitialization( bootMetamodel, - bootMetamodel.getTypeConfiguration().getMetadataBuildingContext().getBootstrapContext(), + bootstrapContext, this ); diff --git a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionManagedImpl.java b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionManagedImpl.java index 3486a39fc2..af0409fc14 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionManagedImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionManagedImpl.java @@ -21,7 +21,6 @@ import org.hibernate.engine.jdbc.spi.SqlExceptionHelper; import org.hibernate.resource.jdbc.ResourceRegistry; import org.hibernate.resource.jdbc.spi.JdbcObserver; import org.hibernate.resource.jdbc.spi.JdbcSessionContext; -import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode; import org.jboss.logging.Logger; @@ -201,14 +200,6 @@ public class LogicalConnectionManagedImpl extends AbstractLogicalConnectionImple } } - @Override - public LogicalConnectionImplementor makeShareableCopy() { - errorIfClosed(); - - // todo : implement - return null; - } - @Override public void serialize(ObjectOutputStream oos) throws IOException { oos.writeBoolean( closed ); diff --git a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionProvidedImpl.java b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionProvidedImpl.java index 9e6ba5d329..b65e3371e5 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionProvidedImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/internal/LogicalConnectionProvidedImpl.java @@ -13,7 +13,6 @@ import java.sql.Connection; import org.hibernate.resource.jdbc.LogicalConnection; import org.hibernate.resource.jdbc.ResourceRegistry; -import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor; import org.hibernate.resource.jdbc.spi.PhysicalConnectionHandlingMode; import org.jboss.logging.Logger; @@ -81,13 +80,6 @@ public class LogicalConnectionProvidedImpl extends AbstractLogicalConnectionImpl return providedConnection; } - @Override - public LogicalConnectionImplementor makeShareableCopy() { - errorIfClosed(); - - return new LogicalConnectionProvidedImpl( providedConnection, new ResourceRegistryStandardImpl() ); - } - @Override public void serialize(ObjectOutputStream oos) throws IOException { oos.writeBoolean( closed ); diff --git a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/LogicalConnectionImplementor.java b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/LogicalConnectionImplementor.java index 04b5617504..8f656183e9 100644 --- a/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/LogicalConnectionImplementor.java +++ b/hibernate-core/src/main/java/org/hibernate/resource/jdbc/spi/LogicalConnectionImplementor.java @@ -59,15 +59,8 @@ public interface LogicalConnectionImplementor extends LogicalConnection { void manualReconnect(Connection suppliedConnection); /** - * Creates a shareable copy of itself for use in "shared sessions" - * - * @return The shareable copy. - * - * @deprecated This method is not used by Hibernate. + * Access to the current underlying JDBC transaction */ - @Deprecated - LogicalConnectionImplementor makeShareableCopy(); - PhysicalJdbcTransaction getPhysicalJdbcTransaction(); /**