diff --git a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java index d33b3098c9..9265c31a2f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java @@ -505,6 +505,9 @@ public abstract class EntityType extends AbstractType implements AssociationType throw new ClassCastException( value.getClass().getName() ); } id = ( Serializable ) value; + } else if ( value instanceof HibernateProxy ) { + HibernateProxy proxy = ( HibernateProxy ) value; + id = proxy.getHibernateLazyInitializer().getIdentifier(); } else { id = persister.getIdentifier( value );