Skip to content

Commit 6a4e990

Browse files
dreab8sebersole
authored andcommitted
HHH-19825 - Add methods and change method access for Hibernate Reactive
1 parent bde5f78 commit 6a4e990

File tree

5 files changed

+65
-9
lines changed

5 files changed

+65
-9
lines changed

hibernate-core/src/main/java/org/hibernate/bytecode/enhance/spi/interceptor/EnhancementAsProxyLazinessInterceptor.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ public boolean hasWrittenFieldNames() {
298298
return writtenFieldNames != null && !writtenFieldNames.isEmpty();
299299
}
300300

301+
/*
302+
* Used by Hibernate Reactive
303+
*/
304+
protected boolean isIdentifier(String attributeName) {
305+
return meta.identifierAttributeNames.contains( attributeName );
306+
}
307+
301308
private enum Status {
302309
UNINITIALIZED,
303310
INITIALIZING,

hibernate-core/src/main/java/org/hibernate/bytecode/internal/BytecodeEnhancementMetadataPojoImpl.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@
4040
*
4141
* @author Steve Ebersole
4242
*/
43-
public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhancementMetadata {
43+
public class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhancementMetadata {
4444
/**
4545
* Static constructor
4646
*/
47-
public static BytecodeEnhancementMetadata from(
47+
public static BytecodeEnhancementMetadataPojoImpl from(
4848
PersistentClass persistentClass,
4949
Set<String> identifierAttributeNames,
5050
CompositeType nonAggregatedCidMapper,
@@ -75,7 +75,10 @@ public static BytecodeEnhancementMetadata from(
7575
private final LazyAttributeLoadingInterceptor.EntityRelatedState lazyAttributeLoadingInterceptorState;
7676
private volatile transient EnhancementAsProxyLazinessInterceptor.EntityRelatedState enhancementAsProxyInterceptorState;
7777

78-
BytecodeEnhancementMetadataPojoImpl(
78+
/*
79+
* Used by Hibernate Reactive
80+
*/
81+
protected BytecodeEnhancementMetadataPojoImpl(
7982
String entityName,
8083
Class<?> entityClass,
8184
Set<String> identifierAttributeNames,
@@ -248,9 +251,12 @@ public void injectEnhancedEntityAsProxyInterceptor(
248251
);
249252
}
250253

254+
/*
255+
* Used by Hibernate Reactive
256+
*/
251257
//This state object needs to be lazily initialized as it needs access to the Persister, but once
252258
//initialized it can be reused across multiple sessions.
253-
private EnhancementAsProxyLazinessInterceptor.EntityRelatedState getEnhancementAsProxyLazinessInterceptorMetastate(SharedSessionContractImplementor session) {
259+
public EnhancementAsProxyLazinessInterceptor.EntityRelatedState getEnhancementAsProxyLazinessInterceptorMetastate(SharedSessionContractImplementor session) {
254260
EnhancementAsProxyLazinessInterceptor.EntityRelatedState state = this.enhancementAsProxyInterceptorState;
255261
if ( state == null ) {
256262
final EntityPersister entityPersister = session.getFactory().getMappingMetamodel()
@@ -311,4 +317,17 @@ public void injectInterceptor(
311317
return (BytecodeLazyAttributeInterceptor) interceptor;
312318
}
313319

320+
/*
321+
* Used by Hibernate Reactive
322+
*/
323+
public Class<?> getEntityClass() {
324+
return entityClass;
325+
}
326+
327+
/*
328+
* Used by Hibernate Reactive
329+
*/
330+
public LazyAttributeLoadingInterceptor.EntityRelatedState getLazyAttributeLoadingInterceptorState() {
331+
return lazyAttributeLoadingInterceptorState;
332+
}
314333
}

hibernate-core/src/main/java/org/hibernate/metamodel/internal/AbstractEntityInstantiatorPojo.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,18 @@ public boolean isInstance(Object object) {
6464
// this one needed only for guessEntityMode()
6565
|| proxyInterface!=null && proxyInterface.isInstance(object);
6666
}
67+
68+
/*
69+
* Used by Hibernate Reactive
70+
*/
71+
protected boolean isApplyBytecodeInterception() {
72+
return applyBytecodeInterception;
73+
}
74+
75+
/*
76+
* Used by Hibernate Reactive
77+
*/
78+
protected LazyAttributeLoadingInterceptor.EntityRelatedState getLoadingInterceptorState() {
79+
return loadingInterceptorState;
80+
}
6781
}

hibernate-core/src/main/java/org/hibernate/metamodel/internal/EntityRepresentationStrategyPojoStandard.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ private Map<String, PropertyAccess> buildPropertyAccessMap(PersistentClass bootD
159159
return propertyAccessMap;
160160
}
161161

162-
private EntityInstantiator determineInstantiator(PersistentClass bootDescriptor, EntityPersister persister) {
162+
/*
163+
* Used by Hibernate Reactive
164+
*/
165+
protected EntityInstantiator determineInstantiator(PersistentClass bootDescriptor, EntityPersister persister) {
163166
if ( reflectionOptimizer != null && reflectionOptimizer.getInstantiationOptimizer() != null ) {
164167
return new EntityInstantiatorPojoOptimized(
165168
persister,

hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ private static boolean isLazy(
528528
);
529529
}
530530

531-
private static BytecodeEnhancementMetadata bytecodeEnhancementMetadata(
531+
private BytecodeEnhancementMetadata bytecodeEnhancementMetadata(
532532
PersistentClass persistentClass,
533533
IdentifierProperty identifierAttribute,
534534
RuntimeModelCreationContext creationContext,
@@ -550,19 +550,32 @@ private static BytecodeEnhancementMetadata bytecodeEnhancementMetadata(
550550
idAttributeNames = singleton( identifierAttribute.getName() );
551551
}
552552

553-
return BytecodeEnhancementMetadataPojoImpl.from(
553+
return getBytecodeEnhancementMetadataPojo(
554554
persistentClass,
555+
creationContext,
555556
idAttributeNames,
556557
nonAggregatedCidMapper,
557-
collectionsInDefaultFetchGroupEnabled,
558-
creationContext.getMetadata()
558+
collectionsInDefaultFetchGroupEnabled
559559
);
560560
}
561561
else {
562562
return new BytecodeEnhancementMetadataNonPojoImpl( persistentClass.getEntityName() );
563563
}
564564
}
565565

566+
/*
567+
* Used by Hibernate Reactive
568+
*/
569+
protected BytecodeEnhancementMetadata getBytecodeEnhancementMetadataPojo(PersistentClass persistentClass, RuntimeModelCreationContext creationContext, Set<String> idAttributeNames, CompositeType nonAggregatedCidMapper, boolean collectionsInDefaultFetchGroupEnabled) {
570+
return BytecodeEnhancementMetadataPojoImpl.from(
571+
persistentClass,
572+
idAttributeNames,
573+
nonAggregatedCidMapper,
574+
collectionsInDefaultFetchGroupEnabled,
575+
creationContext.getMetadata()
576+
);
577+
}
578+
566579
private static boolean writePropertyValue(OnExecutionGenerator generator) {
567580
final boolean writePropertyValue = generator.writePropertyValue();
568581
// TODO: move this validation somewhere else!

0 commit comments

Comments
 (0)