24
24
import org .hibernate .reactive .persister .entity .impl .ReactiveEntityPersister ;
25
25
import org .hibernate .reactive .session .impl .ReactiveQueryExecutorLookup ;
26
26
import org .hibernate .reactive .session .impl .ReactiveSessionImpl ;
27
- import org .hibernate .reactive .util .impl .CompletionStages ;
28
27
import org .hibernate .type .EntityType ;
29
28
import org .hibernate .type .ForeignKeyDirection ;
30
29
import org .hibernate .type .OneToOneType ;
@@ -79,8 +78,11 @@ static boolean isNull(EntityType entityType, Object owner, SharedSessionContract
79
78
OneToOneType type = (OneToOneType ) entityType ;
80
79
String propertyName = type .getPropertyName ();
81
80
if ( propertyName != null ) {
82
- EntityPersister ownerPersister = session .getFactory ().getMetamodel ()
83
- .entityPersister ( entityType .getAssociatedEntityName () );
81
+ final EntityPersister ownerPersister = session .getFactory ()
82
+ .getRuntimeMetamodels ()
83
+ .getMappingMetamodel ()
84
+ .getEntityDescriptor ( entityType .getAssociatedEntityName () );
85
+
84
86
Object id = session .getContextEntityIdentifier ( owner );
85
87
EntityKey entityKey = session .generateEntityKey ( id , ownerPersister );
86
88
return session .getPersistenceContextInternal ().isPropertyNull ( entityKey , propertyName );
@@ -183,7 +185,8 @@ public static CompletionStage<Object[]> replace(
183
185
copyCache
184
186
).thenCompose ( copy -> {
185
187
if ( copy instanceof CompletionStage ) {
186
- return ( (CompletionStage ) copy ).thenAccept ( nonStageCopy -> copied [i ] = nonStageCopy );
188
+ return ( (CompletionStage <?>) copy )
189
+ .thenAccept ( nonStageCopy -> copied [i ] = nonStageCopy );
187
190
}
188
191
else {
189
192
copied [i ] = copy ;
@@ -202,7 +205,7 @@ public static CompletionStage<Object[]> replace(
202
205
final Type [] types ,
203
206
final SessionImplementor session ,
204
207
final Object owner ,
205
- final Map copyCache ,
208
+ final Map < Object , Object > copyCache ,
206
209
final ForeignKeyDirection foreignKeyDirection ) {
207
210
Object [] copied = new Object [original .length ];
208
211
for ( int i = 0 ; i < types .length ; i ++ ) {
@@ -235,7 +238,7 @@ public static CompletionStage<Object[]> replace(
235
238
foreignKeyDirection
236
239
).thenCompose ( copy -> {
237
240
if ( copy instanceof CompletionStage ) {
238
- return ( (CompletionStage ) copy ).thenAccept ( nonStageCopy -> copied [i ] = nonStageCopy );
241
+ return ( (CompletionStage <?> ) copy ).thenAccept ( nonStageCopy -> copied [i ] = nonStageCopy );
239
242
}
240
243
else {
241
244
copied [i ] = copy ;
@@ -254,7 +257,7 @@ private static CompletionStage<Object> replace(
254
257
Object target ,
255
258
SessionImplementor session ,
256
259
Object owner ,
257
- Map copyCache ,
260
+ Map < Object , Object > copyCache ,
258
261
ForeignKeyDirection foreignKeyDirection )
259
262
throws HibernateException {
260
263
boolean include = entityType .isAssociationType ()
@@ -274,7 +277,7 @@ private static CompletionStage<Object> replace(
274
277
Object target ,
275
278
SessionImplementor session ,
276
279
Object owner ,
277
- Map copyCache ) {
280
+ Map < Object , Object > copyCache ) {
278
281
if ( original == null ) {
279
282
return nullFuture ();
280
283
}
@@ -320,11 +323,12 @@ private static CompletionStage<Object> resolveIdOrUniqueKey(
320
323
Object original ,
321
324
SessionImplementor session ,
322
325
Object owner ,
323
- Map copyCache ) {
326
+ Map < Object , Object > copyCache ) {
324
327
return getIdentifier ( entityType , original , session )
325
328
.thenCompose ( id -> {
326
329
if ( id == null ) {
327
- throw new AssertionFailure ( "non-transient entity has a null id: " + original .getClass ().getName () );
330
+ throw new AssertionFailure ( "non-transient entity has a null id: " + original .getClass ()
331
+ .getName () );
328
332
}
329
333
// For the special case of a @ManyToOne joined on a (non-primary) unique key,
330
334
// the "id" class is actually the associated entity object itself, but treated
@@ -336,9 +340,8 @@ private static CompletionStage<Object> resolveIdOrUniqueKey(
336
340
Object idOrUniqueKey = entityType .getIdentifierOrUniqueKeyType ( session .getFactory () )
337
341
.replace ( fetched , null , session , owner , copyCache );
338
342
if ( idOrUniqueKey instanceof CompletionStage ) {
339
- return ( (CompletionStage ) idOrUniqueKey ).thenCompose (
340
- key -> resolve ( entityType , key , owner , session )
341
- );
343
+ return ( (CompletionStage <?>) idOrUniqueKey )
344
+ .thenCompose ( key -> resolve ( entityType , key , owner , session ) );
342
345
}
343
346
344
347
return resolve ( entityType , idOrUniqueKey , owner , session );
@@ -361,8 +364,8 @@ private static CompletionStage<Object> getIdentifier(
361
364
return nullFuture ();
362
365
}
363
366
364
- if ( value instanceof HibernateProxy ) {
365
- return getIdentifierFromHibernateProxy ( entityType , (HibernateProxy )value , session );
367
+ if ( value instanceof HibernateProxy ) {
368
+ return getIdentifierFromHibernateProxy ( entityType , (HibernateProxy ) value , session );
366
369
}
367
370
368
371
final LazyInitializer lazyInitializer = extractLazyInitializer ( value );
@@ -399,7 +402,10 @@ else if ( isPersistentAttributeInterceptable( value ) ) {
399
402
400
403
}
401
404
402
- private static CompletionStage <Object > getIdentifierFromHibernateProxy (EntityType entityType , HibernateProxy proxy , SharedSessionContractImplementor session ) {
405
+ private static CompletionStage <Object > getIdentifierFromHibernateProxy (
406
+ EntityType entityType ,
407
+ HibernateProxy proxy ,
408
+ SharedSessionContractImplementor session ) {
403
409
LazyInitializer initializer = proxy .getHibernateLazyInitializer ();
404
410
final String entityName = initializer .getEntityName ();
405
411
final Object identifier = initializer .getIdentifier ();
@@ -421,7 +427,7 @@ private static CompletionStage<Object> getIdentifierFromHibernateProxy(EntityTyp
421
427
}
422
428
return completedFuture ( propertyValue );
423
429
}
424
- return CompletionStages . nullFuture ();
430
+ return nullFuture ();
425
431
} );
426
432
}
427
433
0 commit comments