diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/bulkid/AbstractMutationStrategyIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/bulkid/AbstractMutationStrategyIdTest.java index c3b6c9265d..76e8f0b141 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/bulkid/AbstractMutationStrategyIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/bulkid/AbstractMutationStrategyIdTest.java @@ -1,16 +1,22 @@ package org.hibernate.orm.test.bulkid; import jakarta.persistence.Entity; +import jakarta.persistence.EntityManager; import jakarta.persistence.GeneratedValue; import jakarta.persistence.Id; import jakarta.persistence.Inheritance; import jakarta.persistence.InheritanceType; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.CriteriaUpdate; +import jakarta.persistence.criteria.Root; import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; +import org.hibernate.orm.test.jpa.compliance.CriteriaMutationQueryTableTest; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.hibernate.testing.orm.junit.Jira; import org.junit.Before; import org.junit.Test; @@ -90,6 +96,22 @@ public abstract class AbstractMutationStrategyIdTest extends BaseCoreFunctionalT }); } + @Test + @Jira( value = "HHH-18373" ) + public void testNullValueUpdateWithCriteria() { + doInHibernate( this::sessionFactory, session -> { + EntityManager entityManager = session.unwrap( EntityManager.class); + + CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + CriteriaUpdate update = cb.createCriteriaUpdate( Person.class ).set( "name", null ); + Root person = update.from( Person.class ); + update.where( cb.equal( person.get( "employed" ), true ) ); + int updateCount = entityManager.createQuery( update ).executeUpdate(); + + assertEquals( entityCount(), updateCount ); + }); + } + @Test public void testDeleteFromPerson() { doInHibernate( this::sessionFactory, session -> {