4242import static org .hibernate .pretty .MessageHelper .infoString ;
4343import static org .hibernate .reactive .id .impl .IdentifierGeneration .assignIdIfNecessary ;
4444import static org .hibernate .reactive .id .impl .IdentifierGeneration .generateId ;
45+ import static org .hibernate .reactive .util .impl .CompletionStages .completedFuture ;
4546import static org .hibernate .reactive .util .impl .CompletionStages .failedFuture ;
47+ import static org .hibernate .reactive .util .impl .CompletionStages .nullFuture ;
4648
4749/**
4850 * Functionality common to persist and merge event listeners.
@@ -164,11 +166,12 @@ protected CompletionStage<Void> reactivePerformSave(
164166 }
165167
166168 CompletionStage <EntityKey > keyStage = useIdentityColumn
167- ? CompletionStages .nullFuture ()
168- : generateEntityKey ( id , persister , source ).thenCompose ( generatedKey -> {
169- persister .setIdentifier ( entity , id , source );
170- return CompletionStages .completedFuture ( generatedKey );
171- } );
169+ ? nullFuture ()
170+ : generateEntityKey ( id , persister , source )
171+ .thenApply ( generatedKey -> {
172+ persister .setIdentifier ( entity , id , source );
173+ return generatedKey ;
174+ } );
172175
173176 return keyStage .thenCompose ( key -> reactivePerformSaveOrReplicate (
174177 entity ,
@@ -181,22 +184,22 @@ protected CompletionStage<Void> reactivePerformSave(
181184 ) );
182185 }
183186
184- private CompletionStage <EntityKey > generateEntityKey (Serializable id , EntityPersister persister ,
185- EventSource source ) {
187+ private CompletionStage <EntityKey > generateEntityKey (Serializable id , EntityPersister persister , EventSource source ) {
186188 final EntityKey key = source .generateEntityKey ( id , persister );
187189 final PersistenceContext persistenceContext = source .getPersistenceContextInternal ();
188190 Object old = persistenceContext .getEntity ( key );
189191 if ( old != null ) {
190192 if ( persistenceContext .getEntry ( old ).getStatus () == Status .DELETED ) {
191- return source .unwrap ( ReactiveSession .class ).reactiveForceFlush (
192- persistenceContext .getEntry ( old ) ).thenApply ( v -> key );
193+ return source .unwrap ( ReactiveSession .class )
194+ .reactiveForceFlush ( persistenceContext .getEntry ( old ) )
195+ .thenApply ( v -> key );
193196 }
194197 else {
195198 return failedFuture ( new NonUniqueObjectException ( id , persister .getEntityName () ) );
196199 }
197200 }
198201
199- return CompletionStages . completedFuture ( key );
202+ return completedFuture ( key );
200203 }
201204
202205 /**
0 commit comments