Skip to content

Commit 7d3255d

Browse files
committed
Clean up FastSessionServices which had become a bucket to dump things in
introduce EventListenerGroups
1 parent 3df8bb6 commit 7d3255d

File tree

44 files changed

+867
-759
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+867
-759
lines changed

hibernate-core/src/main/java/org/hibernate/action/internal/CollectionAction.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.hibernate.engine.spi.ComparableExecutable;
1414
import org.hibernate.engine.spi.SharedSessionContractImplementor;
1515
import org.hibernate.event.spi.EventSource;
16+
import org.hibernate.event.service.spi.EventListenerGroups;
1617
import org.hibernate.internal.FastSessionServices;
1718
import org.hibernate.persister.collection.CollectionPersister;
1819

@@ -197,10 +198,19 @@ protected EventSource eventSource() {
197198

198199
/**
199200
* Convenience method for all subclasses.
200-
* @return the {@link FastSessionServices} instance from the SessionFactory.
201+
* @return the {@link EventListenerGroups} instance from the {@code SessionFactory}.
201202
*/
203+
protected EventListenerGroups getEventListenerGroups() {
204+
return session.getFactory().getEventListenerGroups();
205+
}
206+
207+
/**
208+
* @deprecated This is a layer-breaker
209+
*/
210+
@Deprecated(since = "7.0", forRemoval = true)
202211
protected FastSessionServices getFastSessionServices() {
203212
return session.getFactory().getFastSessionServices();
204213
}
205214

215+
206216
}

hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRecreateAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void execute() throws HibernateException {
6868
}
6969

7070
private void preRecreate() {
71-
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_RECREATE
71+
getEventListenerGroups().eventListenerGroup_PRE_COLLECTION_RECREATE
7272
.fireLazyEventOnEachListener( this::newPreCollectionRecreateEvent,
7373
PreCollectionRecreateEventListener::onPreRecreateCollection );
7474
}
@@ -78,7 +78,7 @@ private PreCollectionRecreateEvent newPreCollectionRecreateEvent() {
7878
}
7979

8080
private void postRecreate() {
81-
getFastSessionServices().eventListenerGroup_POST_COLLECTION_RECREATE
81+
getEventListenerGroups().eventListenerGroup_POST_COLLECTION_RECREATE
8282
.fireLazyEventOnEachListener( this::newPostCollectionRecreateEvent,
8383
PostCollectionRecreateEventListener::onPostRecreateCollection );
8484
}

hibernate-core/src/main/java/org/hibernate/action/internal/CollectionRemoveAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public void execute() throws HibernateException {
138138
}
139139

140140
private void preRemove() {
141-
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_REMOVE
141+
getEventListenerGroups().eventListenerGroup_PRE_COLLECTION_REMOVE
142142
.fireLazyEventOnEachListener( this::newPreCollectionRemoveEvent,
143143
PreCollectionRemoveEventListener::onPreRemoveCollection );
144144
}
@@ -148,7 +148,7 @@ private PreCollectionRemoveEvent newPreCollectionRemoveEvent() {
148148
}
149149

150150
private void postRemove() {
151-
getFastSessionServices().eventListenerGroup_POST_COLLECTION_REMOVE
151+
getEventListenerGroups().eventListenerGroup_POST_COLLECTION_REMOVE
152152
.fireLazyEventOnEachListener( this::newPostCollectionRemoveEvent,
153153
PostCollectionRemoveEventListener::onPostRemoveCollection );
154154
}

hibernate-core/src/main/java/org/hibernate/action/internal/CollectionUpdateAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ else if ( collection.needsRecreate( persister ) ) {
108108
}
109109

110110
private void preUpdate() {
111-
getFastSessionServices().eventListenerGroup_PRE_COLLECTION_UPDATE
111+
getEventListenerGroups().eventListenerGroup_PRE_COLLECTION_UPDATE
112112
.fireLazyEventOnEachListener( this::newPreCollectionUpdateEvent,
113113
PreCollectionUpdateEventListener::onPreUpdateCollection );
114114
}
@@ -118,7 +118,7 @@ private PreCollectionUpdateEvent newPreCollectionUpdateEvent() {
118118
}
119119

120120
private void postUpdate() {
121-
getFastSessionServices().eventListenerGroup_POST_COLLECTION_UPDATE
121+
getEventListenerGroups().eventListenerGroup_POST_COLLECTION_UPDATE
122122
.fireLazyEventOnEachListener( this::newPostCollectionUpdateEvent,
123123
PostCollectionUpdateEventListener::onPostUpdateCollection );
124124
}

hibernate-core/src/main/java/org/hibernate/action/internal/EntityAction.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.hibernate.engine.spi.ComparableExecutable;
1111
import org.hibernate.engine.spi.EntityEntry;
1212
import org.hibernate.event.spi.EventSource;
13+
import org.hibernate.event.service.spi.EventListenerGroups;
1314
import org.hibernate.internal.FastSessionServices;
1415
import org.hibernate.persister.entity.EntityPersister;
1516

@@ -192,10 +193,17 @@ protected final EventSource eventSource() {
192193

193194
/**
194195
* Convenience method for all subclasses.
195-
* @return the {@link FastSessionServices} instance from the SessionFactory.
196+
* @return the {@link EventListenerGroups} instance from the {@code SessionFactory}.
196197
*/
198+
protected EventListenerGroups getEventListenerGroups() {
199+
return session.getFactory().getEventListenerGroups();
200+
}
201+
202+
/**
203+
* @deprecated This is a layer-breaker
204+
*/
205+
@Deprecated(since = "7.0", forRemoval = true)
197206
protected FastSessionServices getFastSessionServices() {
198207
return session.getFactory().getFastSessionServices();
199208
}
200-
201209
}

hibernate-core/src/main/java/org/hibernate/action/internal/EntityDeleteAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ protected void postDeleteUnloaded(Object id, EntityPersister persister, SharedSe
199199

200200
protected boolean preDelete() {
201201
final EventListenerGroup<PreDeleteEventListener> listenerGroup
202-
= getFastSessionServices().eventListenerGroup_PRE_DELETE;
202+
= getEventListenerGroups().eventListenerGroup_PRE_DELETE;
203203
if ( listenerGroup.isEmpty() ) {
204204
return false;
205205
}
@@ -214,7 +214,7 @@ protected boolean preDelete() {
214214
}
215215

216216
protected void postDelete() {
217-
getFastSessionServices().eventListenerGroup_POST_DELETE
217+
getEventListenerGroups().eventListenerGroup_POST_DELETE
218218
.fireLazyEventOnEachListener( this::newPostDeleteEvent, PostDeleteEventListener::onPostDelete );
219219
}
220220

@@ -224,7 +224,7 @@ PostDeleteEvent newPostDeleteEvent() {
224224

225225
protected void postCommitDelete(boolean success) {
226226
final EventListenerGroup<PostDeleteEventListener> eventListeners
227-
= getFastSessionServices().eventListenerGroup_POST_COMMIT_DELETE;
227+
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_DELETE;
228228
if (success) {
229229
eventListeners.fireLazyEventOnEachListener( this::newPostDeleteEvent, PostDeleteEventListener::onPostDelete );
230230
}
@@ -251,7 +251,7 @@ public void doAfterTransactionCompletion(boolean success, SharedSessionContractI
251251

252252
@Override
253253
protected boolean hasPostCommitEventListeners() {
254-
for ( PostDeleteEventListener listener: getFastSessionServices().eventListenerGroup_POST_COMMIT_DELETE.listeners() ) {
254+
for ( PostDeleteEventListener listener: getEventListenerGroups().eventListenerGroup_POST_COMMIT_DELETE.listeners() ) {
255255
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
256256
return true;
257257
}

hibernate-core/src/main/java/org/hibernate/action/internal/EntityIdentityInsertAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public boolean needsAfterTransactionCompletion() {
139139
@Override
140140
protected boolean hasPostCommitEventListeners() {
141141
final EventListenerGroup<PostInsertEventListener> group
142-
= getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT;
142+
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT;
143143
for ( PostInsertEventListener listener : group.listeners() ) {
144144
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
145145
return true;
@@ -163,7 +163,7 @@ protected void postInsert() {
163163
getSession().getPersistenceContextInternal()
164164
.replaceDelayedEntityIdentityInsertKeys( delayedEntityKey, generatedId );
165165
}
166-
getFastSessionServices().eventListenerGroup_POST_INSERT
166+
getEventListenerGroups().eventListenerGroup_POST_INSERT
167167
.fireLazyEventOnEachListener( this::newPostInsertEvent, PostInsertEventListener::onPostInsert );
168168
}
169169

@@ -172,7 +172,7 @@ PostInsertEvent newPostInsertEvent() {
172172
}
173173

174174
protected void postCommitInsert(boolean success) {
175-
getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT
175+
getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT
176176
.fireLazyEventOnEachListener( this::newPostInsertEvent,
177177
success ? PostInsertEventListener::onPostInsert : this::postCommitInsertOnFailure );
178178
}
@@ -189,7 +189,7 @@ private void postCommitInsertOnFailure(PostInsertEventListener listener, PostIns
189189

190190
protected boolean preInsert() {
191191
final EventListenerGroup<PreInsertEventListener> listenerGroup
192-
= getFastSessionServices().eventListenerGroup_PRE_INSERT;
192+
= getEventListenerGroups().eventListenerGroup_PRE_INSERT;
193193
if ( listenerGroup.isEmpty() ) {
194194
// NO_VETO
195195
return false;

hibernate-core/src/main/java/org/hibernate/action/internal/EntityInsertAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ protected boolean cacheInsert(EntityPersister persister, Object ck) {
210210
}
211211

212212
protected void postInsert() {
213-
getFastSessionServices()
213+
getEventListenerGroups()
214214
.eventListenerGroup_POST_INSERT
215215
.fireLazyEventOnEachListener( this::newPostInsertEvent, PostInsertEventListener::onPostInsert );
216216
}
@@ -220,7 +220,7 @@ private PostInsertEvent newPostInsertEvent() {
220220
}
221221

222222
protected void postCommitInsert(boolean success) {
223-
getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT
223+
getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT
224224
.fireLazyEventOnEachListener( this::newPostInsertEvent,
225225
success ? PostInsertEventListener::onPostInsert : this::postCommitOnFailure );
226226
}
@@ -237,7 +237,7 @@ private void postCommitOnFailure(PostInsertEventListener listener, PostInsertEve
237237

238238
protected boolean preInsert() {
239239
final EventListenerGroup<PreInsertEventListener> listenerGroup
240-
= getFastSessionServices().eventListenerGroup_PRE_INSERT;
240+
= getEventListenerGroups().eventListenerGroup_PRE_INSERT;
241241
if ( listenerGroup.isEmpty() ) {
242242
return false;
243243
}
@@ -298,7 +298,7 @@ protected boolean cacheAfterInsert(EntityDataAccess cache, Object ck) {
298298
@Override
299299
protected boolean hasPostCommitEventListeners() {
300300
final EventListenerGroup<PostInsertEventListener> group
301-
= getFastSessionServices().eventListenerGroup_POST_COMMIT_INSERT;
301+
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_INSERT;
302302
for ( PostInsertEventListener listener : group.listeners() ) {
303303
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
304304
return true;

hibernate-core/src/main/java/org/hibernate/action/internal/EntityUpdateAction.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ protected boolean updateCache(EntityPersister persister, Object previousVersion,
352352

353353
protected boolean preUpdate() {
354354
final EventListenerGroup<PreUpdateEventListener> listenerGroup
355-
= getFastSessionServices().eventListenerGroup_PRE_UPDATE;
355+
= getEventListenerGroups().eventListenerGroup_PRE_UPDATE;
356356
if ( listenerGroup.isEmpty() ) {
357357
return false;
358358
}
@@ -368,7 +368,7 @@ protected boolean preUpdate() {
368368
}
369369

370370
protected void postUpdate() {
371-
getFastSessionServices().eventListenerGroup_POST_UPDATE
371+
getEventListenerGroups().eventListenerGroup_POST_UPDATE
372372
.fireLazyEventOnEachListener( this::newPostUpdateEvent, PostUpdateEventListener::onPostUpdate );
373373
}
374374

@@ -377,7 +377,7 @@ private PostUpdateEvent newPostUpdateEvent() {
377377
}
378378

379379
protected void postCommitUpdate(boolean success) {
380-
getFastSessionServices().eventListenerGroup_POST_COMMIT_UPDATE
380+
getEventListenerGroups().eventListenerGroup_POST_COMMIT_UPDATE
381381
.fireLazyEventOnEachListener( this::newPostUpdateEvent,
382382
success ? PostUpdateEventListener::onPostUpdate : this::onPostCommitFailure );
383383
}
@@ -395,7 +395,7 @@ private void onPostCommitFailure(PostUpdateEventListener listener, PostUpdateEve
395395
@Override
396396
protected boolean hasPostCommitEventListeners() {
397397
final EventListenerGroup<PostUpdateEventListener> group
398-
= getFastSessionServices().eventListenerGroup_POST_COMMIT_UPDATE;
398+
= getEventListenerGroups().eventListenerGroup_POST_COMMIT_UPDATE;
399399
for ( PostUpdateEventListener listener : group.listeners() ) {
400400
if ( listener.requiresPostCommitHandling( getPersister() ) ) {
401401
return true;

hibernate-core/src/main/java/org/hibernate/boot/internal/NamedProcedureCallDefinitionImpl.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,7 @@ else if ( specifiesResultSetMappings ) {
133133
}
134134

135135
private ResultSetMapping buildResultSetMapping(String registeredName, SessionFactoryImplementor sessionFactory) {
136-
return sessionFactory
137-
.getFastSessionServices()
138-
.getJdbcValuesMappingProducerProvider()
136+
return sessionFactory.getJdbcValuesMappingProducerProvider()
139137
.buildResultSetMapping( registeredName, false, sessionFactory );
140138
}
141139

0 commit comments

Comments
 (0)