Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ public boolean hasWrittenFieldNames() {
return writtenFieldNames != null && !writtenFieldNames.isEmpty();
}

/*
* Used by Hibernate Reactive
*/
protected boolean isIdentifier(String attributeName) {
return meta.identifierAttributeNames.contains( attributeName );
}

private enum Status {
UNINITIALIZED,
INITIALIZING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@
*
* @author Steve Ebersole
*/
public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhancementMetadata {
public class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhancementMetadata {
/**
* Static constructor
*/
public static BytecodeEnhancementMetadata from(
public static BytecodeEnhancementMetadataPojoImpl from(
PersistentClass persistentClass,
Set<String> identifierAttributeNames,
CompositeType nonAggregatedCidMapper,
Expand Down Expand Up @@ -75,7 +75,10 @@ public static BytecodeEnhancementMetadata from(
private final LazyAttributeLoadingInterceptor.EntityRelatedState lazyAttributeLoadingInterceptorState;
private volatile transient EnhancementAsProxyLazinessInterceptor.EntityRelatedState enhancementAsProxyInterceptorState;

BytecodeEnhancementMetadataPojoImpl(
/*
* Used by Hibernate Reactive
*/
protected BytecodeEnhancementMetadataPojoImpl(
String entityName,
Class<?> entityClass,
Set<String> identifierAttributeNames,
Expand Down Expand Up @@ -248,9 +251,12 @@ public void injectEnhancedEntityAsProxyInterceptor(
);
}

/*
* Used by Hibernate Reactive
*/
//This state object needs to be lazily initialized as it needs access to the Persister, but once
//initialized it can be reused across multiple sessions.
private EnhancementAsProxyLazinessInterceptor.EntityRelatedState getEnhancementAsProxyLazinessInterceptorMetastate(SharedSessionContractImplementor session) {
public EnhancementAsProxyLazinessInterceptor.EntityRelatedState getEnhancementAsProxyLazinessInterceptorMetastate(SharedSessionContractImplementor session) {
EnhancementAsProxyLazinessInterceptor.EntityRelatedState state = this.enhancementAsProxyInterceptorState;
if ( state == null ) {
final EntityPersister entityPersister = session.getFactory().getMappingMetamodel()
Expand Down Expand Up @@ -311,4 +317,17 @@ public void injectInterceptor(
return (BytecodeLazyAttributeInterceptor) interceptor;
}

/*
* Used by Hibernate Reactive
*/
public Class<?> getEntityClass() {
return entityClass;
}

/*
* Used by Hibernate Reactive
*/
public LazyAttributeLoadingInterceptor.EntityRelatedState getLazyAttributeLoadingInterceptorState() {
return lazyAttributeLoadingInterceptorState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,18 @@ public boolean isInstance(Object object) {
// this one needed only for guessEntityMode()
|| proxyInterface!=null && proxyInterface.isInstance(object);
}

/*
* Used by Hibernate Reactive
*/
protected boolean isApplyBytecodeInterception() {
return applyBytecodeInterception;
}

/*
* Used by Hibernate Reactive
*/
protected LazyAttributeLoadingInterceptor.EntityRelatedState getLoadingInterceptorState() {
return loadingInterceptorState;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ private Map<String, PropertyAccess> buildPropertyAccessMap(PersistentClass bootD
return propertyAccessMap;
}

private EntityInstantiator determineInstantiator(PersistentClass bootDescriptor, EntityPersister persister) {
/*
* Used by Hibernate Reactive
*/
protected EntityInstantiator determineInstantiator(PersistentClass bootDescriptor, EntityPersister persister) {
if ( reflectionOptimizer != null && reflectionOptimizer.getInstantiationOptimizer() != null ) {
return new EntityInstantiatorPojoOptimized(
persister,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private static boolean isLazy(
);
}

private static BytecodeEnhancementMetadata bytecodeEnhancementMetadata(
private BytecodeEnhancementMetadata bytecodeEnhancementMetadata(
PersistentClass persistentClass,
IdentifierProperty identifierAttribute,
RuntimeModelCreationContext creationContext,
Expand All @@ -550,19 +550,32 @@ private static BytecodeEnhancementMetadata bytecodeEnhancementMetadata(
idAttributeNames = singleton( identifierAttribute.getName() );
}

return BytecodeEnhancementMetadataPojoImpl.from(
return getBytecodeEnhancementMetadataPojo(
persistentClass,
creationContext,
idAttributeNames,
nonAggregatedCidMapper,
collectionsInDefaultFetchGroupEnabled,
creationContext.getMetadata()
collectionsInDefaultFetchGroupEnabled
);
}
else {
return new BytecodeEnhancementMetadataNonPojoImpl( persistentClass.getEntityName() );
}
}

/*
* Used by Hibernate Reactive
*/
protected BytecodeEnhancementMetadata getBytecodeEnhancementMetadataPojo(PersistentClass persistentClass, RuntimeModelCreationContext creationContext, Set<String> idAttributeNames, CompositeType nonAggregatedCidMapper, boolean collectionsInDefaultFetchGroupEnabled) {
return BytecodeEnhancementMetadataPojoImpl.from(
persistentClass,
idAttributeNames,
nonAggregatedCidMapper,
collectionsInDefaultFetchGroupEnabled,
creationContext.getMetadata()
);
}

private static boolean writePropertyValue(OnExecutionGenerator generator) {
final boolean writePropertyValue = generator.writePropertyValue();
// TODO: move this validation somewhere else!
Expand Down