diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java index 9a391614a6..05039e1e14 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/DiscriminatorType.java @@ -109,9 +109,9 @@ public class DiscriminatorType extends AbstractType { Object value, int index, SessionImplementor session) throws HibernateException, SQLException { - throw new UnsupportedOperationException( - "At the moment this type is not the one actually used to map the discriminator." - ); + String entityName = session.getFactory().getClassMetadata((Class) value).getEntityName(); + Loadable entityPersister = (Loadable) session.getFactory().getEntityPersister(entityName); + underlyingType.nullSafeSet(st, entityPersister.getDiscriminatorValue(), index, session); } public String toLoggableString(Object value, SessionFactoryImplementor factory) throws HibernateException {