Skip to content

Commit ab96246

Browse files
dreab8beikov
authored andcommitted
HHH-18147 Hibernate fails to persist an entity when a natural id association is a proxy
1 parent aba0c6f commit ab96246

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hibernate-core/src/main/java/org/hibernate/metamodel/mapping/internal/ToOneAttributeMapping.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@
6464
import org.hibernate.persister.entity.EntityPersister;
6565
import org.hibernate.persister.entity.JoinedSubclassEntityPersister;
6666
import org.hibernate.property.access.spi.PropertyAccess;
67+
import org.hibernate.proxy.HibernateProxy;
68+
import org.hibernate.proxy.LazyInitializer;
6769
import org.hibernate.spi.EntityIdentifierNavigablePath;
6870
import org.hibernate.spi.NavigablePath;
6971
import org.hibernate.spi.TreatedNavigablePath;
@@ -2365,6 +2367,10 @@ private Object extractValue(Object domainValue, SharedSessionContractImplementor
23652367
}
23662368

23672369
if ( referencedPropertyName != null ) {
2370+
final LazyInitializer lazyInitializer = HibernateProxy.extractLazyInitializer( domainValue );
2371+
if ( lazyInitializer != null ) {
2372+
domainValue = lazyInitializer.getImplementation();
2373+
}
23682374
assert getAssociatedEntityMappingType()
23692375
.getRepresentationStrategy()
23702376
.getInstantiator()

0 commit comments

Comments
 (0)