Skip to content

Commit 8b96b01

Browse files
committed
HHH-19825 Add methods and change method access for Hibernate Reactive
1 parent b516a81 commit 8b96b01

File tree

5 files changed

+64
-9
lines changed

5 files changed

+64
-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
@@ -300,6 +300,13 @@ public boolean hasWrittenFieldNames() {
300300
return writtenFieldNames != null && !writtenFieldNames.isEmpty();
301301
}
302302

303+
/*
304+
* Used by Hibernate Reactive
305+
*/
306+
protected boolean isIdentifier(String attributeName) {
307+
return meta.identifierAttributeNames.contains( attributeName );
308+
}
309+
303310
private enum Status {
304311
UNINITIALIZED,
305312
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
@@ -66,4 +66,18 @@ public boolean isInstance(Object object) {
6666
// this one needed only for guessEntityMode()
6767
|| proxyInterface!=null && proxyInterface.isInstance(object);
6868
}
69+
70+
/*
71+
* Used by Hibernate Reactive
72+
*/
73+
protected boolean isApplyBytecodeInterception() {
74+
return applyBytecodeInterception;
75+
}
76+
77+
/*
78+
* Used by Hibernate Reactive
79+
*/
80+
protected LazyAttributeLoadingInterceptor.EntityRelatedState getLoadingInterceptorState() {
81+
return loadingInterceptorState;
82+
}
6983
}

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
@@ -163,7 +163,10 @@ private Map<String, PropertyAccess> buildPropertyAccessMap(PersistentClass bootD
163163
return propertyAccessMap;
164164
}
165165

166-
private EntityInstantiator determineInstantiator(PersistentClass bootDescriptor, EntityMetamodel entityMetamodel) {
166+
/*
167+
* Used by Hibernate Reactive
168+
*/
169+
protected EntityInstantiator determineInstantiator(PersistentClass bootDescriptor, EntityMetamodel entityMetamodel) {
167170
if ( reflectionOptimizer != null && reflectionOptimizer.getInstantiationOptimizer() != null ) {
168171
return new EntityInstantiatorPojoOptimized(
169172
entityMetamodel,

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

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,12 @@ public EntityMetamodel(
205205
idAttributeNames = singleton( identifierAttribute.getName() );
206206
}
207207

208-
bytecodeEnhancementMetadata = BytecodeEnhancementMetadataPojoImpl.from(
208+
bytecodeEnhancementMetadata = getBytecodeEnhancementMetadataPojo(
209209
persistentClass,
210+
creationContext,
210211
idAttributeNames,
211212
nonAggregatedCidMapper,
212-
collectionsInDefaultFetchGroupEnabled,
213-
creationContext.getMetadata()
214-
);
213+
collectionsInDefaultFetchGroupEnabled );
215214
}
216215
else {
217216
bytecodeEnhancementMetadata = new BytecodeEnhancementMetadataNonPojoImpl( persistentClass.getEntityName() );
@@ -512,6 +511,19 @@ && isAbstractClass( persistentClass.getMappedClass() ) ) {
512511
// entityNameByInheritanceClassMap = toSmallMap( entityNameByInheritanceClassMapLocal );
513512
}
514513

514+
/*
515+
* Used by Hibernate Reactive
516+
*/
517+
protected BytecodeEnhancementMetadata getBytecodeEnhancementMetadataPojo(PersistentClass persistentClass, RuntimeModelCreationContext creationContext, Set<String> idAttributeNames, CompositeType nonAggregatedCidMapper, boolean collectionsInDefaultFetchGroupEnabled) {
518+
return BytecodeEnhancementMetadataPojoImpl.from(
519+
persistentClass,
520+
idAttributeNames,
521+
nonAggregatedCidMapper,
522+
collectionsInDefaultFetchGroupEnabled,
523+
creationContext.getMetadata()
524+
);
525+
}
526+
515527
private static boolean writePropertyValue(OnExecutionGenerator generator) {
516528
final boolean writePropertyValue = generator.writePropertyValue();
517529
// TODO: move this validation somewhere else!

0 commit comments

Comments
 (0)