Skip to content

Commit 9bce274

Browse files
committed
HHH-19899 Do not create (unnecessary) proxy classes for abstract classes in @ConcreteProxy hierarchies
1 parent 4d540f3 commit 9bce274

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,12 @@ private ProxyFactory resolveProxyFactory(
128128
JavaType<?> proxyJavaType,
129129
BytecodeProvider bytecodeProvider,
130130
RuntimeModelCreationContext creationContext) {
131-
// todo : `@ConcreteProxy` handling
132-
if ( entityPersister.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading()
131+
if ( entityPersister.isAbstract() && bootDescriptor.isConcreteProxy() ) {
132+
// The entity class is abstract, but the hierarchy always gets entities loaded/proxied using their concrete type.
133+
// So we do not need proxies for this entity class.
134+
return null;
135+
}
136+
else if ( entityPersister.getBytecodeEnhancementMetadata().isEnhancedForLazyLoading()
133137
&& bootDescriptor.getRootClass() == bootDescriptor
134138
&& !bootDescriptor.hasSubclasses() ) {
135139
// the entity is bytecode enhanced for lazy loading

0 commit comments

Comments
 (0)