42
42
import static org .hibernate .pretty .MessageHelper .infoString ;
43
43
import static org .hibernate .reactive .id .impl .IdentifierGeneration .assignIdIfNecessary ;
44
44
import static org .hibernate .reactive .id .impl .IdentifierGeneration .generateId ;
45
+ import static org .hibernate .reactive .util .impl .CompletionStages .completedFuture ;
45
46
import static org .hibernate .reactive .util .impl .CompletionStages .failedFuture ;
47
+ import static org .hibernate .reactive .util .impl .CompletionStages .nullFuture ;
46
48
47
49
/**
48
50
* Functionality common to persist and merge event listeners.
@@ -164,11 +166,12 @@ protected CompletionStage<Void> reactivePerformSave(
164
166
}
165
167
166
168
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
+ } );
172
175
173
176
return keyStage .thenCompose ( key -> reactivePerformSaveOrReplicate (
174
177
entity ,
@@ -181,22 +184,22 @@ protected CompletionStage<Void> reactivePerformSave(
181
184
) );
182
185
}
183
186
184
- private CompletionStage <EntityKey > generateEntityKey (Serializable id , EntityPersister persister ,
185
- EventSource source ) {
187
+ private CompletionStage <EntityKey > generateEntityKey (Serializable id , EntityPersister persister , EventSource source ) {
186
188
final EntityKey key = source .generateEntityKey ( id , persister );
187
189
final PersistenceContext persistenceContext = source .getPersistenceContextInternal ();
188
190
Object old = persistenceContext .getEntity ( key );
189
191
if ( old != null ) {
190
192
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 );
193
196
}
194
197
else {
195
198
return failedFuture ( new NonUniqueObjectException ( id , persister .getEntityName () ) );
196
199
}
197
200
}
198
201
199
- return CompletionStages . completedFuture ( key );
202
+ return completedFuture ( key );
200
203
}
201
204
202
205
/**
0 commit comments