Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -133,9 +133,7 @@ else if ( specifiesResultSetMappings ) {
}

private ResultSetMapping buildResultSetMapping(String registeredName, SessionFactoryImplementor sessionFactory) {
return sessionFactory
.getFastSessionServices()
.getJdbcValuesMappingProducerProvider()
return sessionFactory.getJdbcValuesMappingProducerProvider()
.buildResultSetMapping( registeredName, false, sessionFactory );
}

Expand Down
Loading
Loading