Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.hibernate.engine.spi.ComparableExecutable;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.service.spi.EventListenerGroups;
import org.hibernate.internal.FastSessionServices;
import org.hibernate.persister.collection.CollectionPersister;

Expand Down Expand Up @@ -197,10 +198,19 @@ protected EventSource eventSource() {

/**
* Convenience method for all subclasses.
* @return the {@link FastSessionServices} instance from the SessionFactory.
* @return the {@link EventListenerGroups} instance from the {@code SessionFactory}.
*/
protected EventListenerGroups getEventListenerGroups() {
return session.getFactory().getEventListenerGroups();
}

/**
* @deprecated This is a layer-breaker
*/
@Deprecated(since = "7.0", forRemoval = true)
protected FastSessionServices getFastSessionServices() {
return session.getFactory().getFastSessionServices();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void execute() throws HibernateException {
}

private void preRecreate() {
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_RECREATE
getEventListenerGroups().eventListenerGroup_PRE_COLLECTION_RECREATE
.fireLazyEventOnEachListener( this::newPreCollectionRecreateEvent,
PreCollectionRecreateEventListener::onPreRecreateCollection );
}
Expand All @@ -78,7 +78,7 @@ private PreCollectionRecreateEvent newPreCollectionRecreateEvent() {
}

private void postRecreate() {
getFastSessionServices().eventListenerGroup_POST_COLLECTION_RECREATE
getEventListenerGroups().eventListenerGroup_POST_COLLECTION_RECREATE
.fireLazyEventOnEachListener( this::newPostCollectionRecreateEvent,
PostCollectionRecreateEventListener::onPostRecreateCollection );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void execute() throws HibernateException {
}

private void preRemove() {
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_REMOVE
getEventListenerGroups().eventListenerGroup_PRE_COLLECTION_REMOVE
.fireLazyEventOnEachListener( this::newPreCollectionRemoveEvent,
PreCollectionRemoveEventListener::onPreRemoveCollection );
}
Expand All @@ -148,7 +148,7 @@ private PreCollectionRemoveEvent newPreCollectionRemoveEvent() {
}

private void postRemove() {
getFastSessionServices().eventListenerGroup_POST_COLLECTION_REMOVE
getEventListenerGroups().eventListenerGroup_POST_COLLECTION_REMOVE
.fireLazyEventOnEachListener( this::newPostCollectionRemoveEvent,
PostCollectionRemoveEventListener::onPostRemoveCollection );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ else if ( collection.needsRecreate( persister ) ) {
}

private void preUpdate() {
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_UPDATE
getEventListenerGroups().eventListenerGroup_PRE_COLLECTION_UPDATE
.fireLazyEventOnEachListener( this::newPreCollectionUpdateEvent,
PreCollectionUpdateEventListener::onPreUpdateCollection );
}
Expand All @@ -118,7 +118,7 @@ private PreCollectionUpdateEvent newPreCollectionUpdateEvent() {
}

private void postUpdate() {
getFastSessionServices().eventListenerGroup_POST_COLLECTION_UPDATE
getEventListenerGroups().eventListenerGroup_POST_COLLECTION_UPDATE
.fireLazyEventOnEachListener( this::newPostCollectionUpdateEvent,
PostCollectionUpdateEventListener::onPostUpdateCollection );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.hibernate.engine.spi.ComparableExecutable;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.event.spi.EventSource;
import org.hibernate.event.service.spi.EventListenerGroups;
import org.hibernate.internal.FastSessionServices;
import org.hibernate.persister.entity.EntityPersister;

Expand Down Expand Up @@ -192,10 +193,17 @@ protected final EventSource eventSource() {

/**
* Convenience method for all subclasses.
* @return the {@link FastSessionServices} instance from the SessionFactory.
* @return the {@link EventListenerGroups} instance from the {@code SessionFactory}.
*/
protected EventListenerGroups getEventListenerGroups() {
return session.getFactory().getEventListenerGroups();
}

/**
* @deprecated This is a layer-breaker
*/
@Deprecated(since = "7.0", forRemoval = true)
protected FastSessionServices getFastSessionServices() {
return session.getFactory().getFastSessionServices();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@

protected boolean preDelete() {
final EventListenerGroup<PreDeleteEventListener> listenerGroup
= getFastSessionServices().eventListenerGroup_PRE_DELETE;
= getEventListenerGroups().eventListenerGroup_PRE_DELETE;
if ( listenerGroup.isEmpty() ) {
return false;
}
Expand All @@ -214,7 +214,7 @@
}

protected void postDelete() {
getFastSessionServices().eventListenerGroup_POST_DELETE
getEventListenerGroups().eventListenerGroup_POST_DELETE
.fireLazyEventOnEachListener( this::newPostDeleteEvent, PostDeleteEventListener::onPostDelete );
}

Expand All @@ -224,7 +224,7 @@

protected void postCommitDelete(boolean success) {
final EventListenerGroup<PostDeleteEventListener> eventListeners
= getFastSessionServices().eventListenerGroup_POST_COMMIT_DELETE;
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_DELETE;
if (success) {
eventListeners.fireLazyEventOnEachListener( this::newPostDeleteEvent, PostDeleteEventListener::onPostDelete );
}
Expand All @@ -251,7 +251,7 @@

@Override
protected boolean hasPostCommitEventListeners() {
for ( PostDeleteEventListener listener: getFastSessionServices().eventListenerGroup_POST_COMMIT_DELETE.listeners() ) {
for ( PostDeleteEventListener listener: getEventListenerGroups().eventListenerGroup_POST_COMMIT_DELETE.listeners() ) {

Check notice

Code scanning / CodeQL

Deprecated method or constructor invocation Note

Invoking
EventListenerGroup.listeners
should be avoided because it has been deprecated.
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public boolean needsAfterTransactionCompletion() {
@Override
protected boolean hasPostCommitEventListeners() {
final EventListenerGroup<PostInsertEventListener> group
= getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT;
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT;
for ( PostInsertEventListener listener : group.listeners() ) {
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
return true;
Expand All @@ -163,7 +163,7 @@ protected void postInsert() {
getSession().getPersistenceContextInternal()
.replaceDelayedEntityIdentityInsertKeys( delayedEntityKey, generatedId );
}
getFastSessionServices().eventListenerGroup_POST_INSERT
getEventListenerGroups().eventListenerGroup_POST_INSERT
.fireLazyEventOnEachListener( this::newPostInsertEvent, PostInsertEventListener::onPostInsert );
}

Expand All @@ -172,7 +172,7 @@ PostInsertEvent newPostInsertEvent() {
}

protected void postCommitInsert(boolean success) {
getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT
getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT
.fireLazyEventOnEachListener( this::newPostInsertEvent,
success ? PostInsertEventListener::onPostInsert : this::postCommitInsertOnFailure );
}
Expand All @@ -189,7 +189,7 @@ private void postCommitInsertOnFailure(PostInsertEventListener listener, PostIns

protected boolean preInsert() {
final EventListenerGroup<PreInsertEventListener> listenerGroup
= getFastSessionServices().eventListenerGroup_PRE_INSERT;
= getEventListenerGroups().eventListenerGroup_PRE_INSERT;
if ( listenerGroup.isEmpty() ) {
// NO_VETO
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ protected boolean cacheInsert(EntityPersister persister, Object ck) {
}

protected void postInsert() {
getFastSessionServices()
getEventListenerGroups()
.eventListenerGroup_POST_INSERT
.fireLazyEventOnEachListener( this::newPostInsertEvent, PostInsertEventListener::onPostInsert );
}
Expand All @@ -220,7 +220,7 @@ private PostInsertEvent newPostInsertEvent() {
}

protected void postCommitInsert(boolean success) {
getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT
getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT
.fireLazyEventOnEachListener( this::newPostInsertEvent,
success ? PostInsertEventListener::onPostInsert : this::postCommitOnFailure );
}
Expand All @@ -237,7 +237,7 @@ private void postCommitOnFailure(PostInsertEventListener listener, PostInsertEve

protected boolean preInsert() {
final EventListenerGroup<PreInsertEventListener> listenerGroup
= getFastSessionServices().eventListenerGroup_PRE_INSERT;
= getEventListenerGroups().eventListenerGroup_PRE_INSERT;
if ( listenerGroup.isEmpty() ) {
return false;
}
Expand Down Expand Up @@ -298,7 +298,7 @@ protected boolean cacheAfterInsert(EntityDataAccess cache, Object ck) {
@Override
protected boolean hasPostCommitEventListeners() {
final EventListenerGroup<PostInsertEventListener> group
= getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT;
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT;
for ( PostInsertEventListener listener : group.listeners() ) {
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ protected boolean updateCache(EntityPersister persister, Object previousVersion,

protected boolean preUpdate() {
final EventListenerGroup<PreUpdateEventListener> listenerGroup
= getFastSessionServices().eventListenerGroup_PRE_UPDATE;
= getEventListenerGroups().eventListenerGroup_PRE_UPDATE;
if ( listenerGroup.isEmpty() ) {
return false;
}
Expand All @@ -368,7 +368,7 @@ protected boolean preUpdate() {
}

protected void postUpdate() {
getFastSessionServices().eventListenerGroup_POST_UPDATE
getEventListenerGroups().eventListenerGroup_POST_UPDATE
.fireLazyEventOnEachListener( this::newPostUpdateEvent, PostUpdateEventListener::onPostUpdate );
}

Expand All @@ -377,7 +377,7 @@ private PostUpdateEvent newPostUpdateEvent() {
}

protected void postCommitUpdate(boolean success) {
getFastSessionServices().eventListenerGroup_POST_COMMIT_UPDATE
getEventListenerGroups().eventListenerGroup_POST_COMMIT_UPDATE
.fireLazyEventOnEachListener( this::newPostUpdateEvent,
success ? PostUpdateEventListener::onPostUpdate : this::onPostCommitFailure );
}
Expand All @@ -395,7 +395,7 @@ private void onPostCommitFailure(PostUpdateEventListener listener, PostUpdateEve
@Override
protected boolean hasPostCommitEventListeners() {
final EventListenerGroup<PostUpdateEventListener> group
= getFastSessionServices().eventListenerGroup_POST_COMMIT_UPDATE;
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_UPDATE;
for ( PostUpdateEventListener listener : group.listeners() ) {
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
import org.hibernate.type.BasicType;
import org.hibernate.type.spi.TypeConfiguration;

Expand All @@ -53,8 +54,10 @@ public class BootstrapContextImpl implements BootstrapContext {
private final SqmFunctionRegistry sqmFunctionRegistry;
private final MutableJpaCompliance jpaCompliance;

private final ClassLoaderService classLoaderService;
private final ClassLoaderAccessImpl classLoaderAccess;
private final BeanInstanceProducer beanInstanceProducer;
private final ManagedBeanRegistry managedBeanRegistry;

private boolean isJpaBootstrap;

Expand All @@ -72,6 +75,7 @@ public class BootstrapContextImpl implements BootstrapContext {
private HashMap<Class<?>, ConverterDescriptor> attributeConverterDescriptorMap;
private ArrayList<CacheRegionDefinition> cacheRegionDefinitions;
private final ManagedTypeRepresentationResolver representationStrategySelector;
private ConfigurationService configurationService;

public BootstrapContextImpl(
StandardServiceRegistry serviceRegistry,
Expand All @@ -80,7 +84,8 @@ public BootstrapContextImpl(
this.classmateContext = new ClassmateContext();
this.metadataBuildingOptions = metadataBuildingOptions;

this.classLoaderAccess = new ClassLoaderAccessImpl( serviceRegistry.getService( ClassLoaderService.class ) );
this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
this.classLoaderAccess = new ClassLoaderAccessImpl( classLoaderService );

final StrategySelector strategySelector = serviceRegistry.requireService( StrategySelector.class );
final ConfigurationService configService = serviceRegistry.requireService( ConfigurationService.class );
Expand All @@ -103,6 +108,9 @@ public BootstrapContextImpl(
this.typeConfiguration = new TypeConfiguration();
this.beanInstanceProducer = new TypeBeanInstanceProducer( configService, serviceRegistry );
this.sqmFunctionRegistry = new SqmFunctionRegistry();

this.managedBeanRegistry = serviceRegistry.requireService( ManagedBeanRegistry.class );
this.configurationService = serviceRegistry.requireService( ConfigurationService.class );
}

@Override
Expand Down Expand Up @@ -135,6 +143,21 @@ public MetadataBuildingOptions getMetadataBuildingOptions() {
return metadataBuildingOptions;
}

@Override
public ClassLoaderService getClassLoaderService() {
return classLoaderService;
}

@Override
public ManagedBeanRegistry getManagedBeanRegistry() {
return managedBeanRegistry;
}

@Override
public ConfigurationService getConfigurationService() {
return configurationService;
}

@Override
public boolean isJpaBootstrap() {
return isJpaBootstrap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ public Class<?> classForName(String name) {
private boolean isSafeClass(String name) {
// classes in any of these packages are safe to load through the "live" ClassLoader
return name.startsWith( "java." )
|| name.startsWith( "javax." )
|| name.startsWith( "jakarta." )
|| name.startsWith( "org.hibernate." );
|| name.startsWith( "javax." )
|| name.startsWith( "jakarta." )
|| name.startsWith( "org.hibernate." );

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public InFlightMetadataCollectorImpl(BootstrapContext bootstrapContext, Metadata
}

private static SourceModelBuildingContext createModelBuildingContext(BootstrapContext bootstrapContext) {
final ClassLoaderService classLoaderService = bootstrapContext.getServiceRegistry().getService( ClassLoaderService.class );
final ClassLoaderService classLoaderService = bootstrapContext.getClassLoaderService();
final ClassLoaderServiceLoading classLoading = new ClassLoaderServiceLoading( classLoaderService );

final ModelsConfiguration modelsConfiguration = new ModelsConfiguration();
Expand Down
Loading
Loading