diff --git a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/CriteriaUpdateImpl.java b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/CriteriaUpdateImpl.java index 4e67d7161b..3fd79d348b 100644 --- a/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/CriteriaUpdateImpl.java +++ b/hibernate-entitymanager/src/main/java/org/hibernate/jpa/criteria/CriteriaUpdateImpl.java @@ -142,12 +142,12 @@ public class CriteriaUpdateImpl extends AbstractManipulationCriteriaQuery jpaql.append( " set " ); boolean first = true; for ( Assignment assignment : assignments ) { - jpaql.append( assignment.attributePath.render( renderingContext ) ) - .append( " = " ) - .append( assignment.value.render( renderingContext ) ); if ( ! first ) { jpaql.append( ", " ); } + jpaql.append( assignment.attributePath.render( renderingContext ) ) + .append( " = " ) + .append( assignment.value.render( renderingContext ) ); first = false; } } diff --git a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/ManipulationCriteriaTest.java b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/ManipulationCriteriaTest.java index 3fc0b9c8be..2897693161 100644 --- a/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/ManipulationCriteriaTest.java +++ b/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/ManipulationCriteriaTest.java @@ -39,6 +39,7 @@ import org.hibernate.jpa.test.metamodel.AbstractMetamodelSpecificTest; import org.hibernate.jpa.test.metamodel.Customer; import org.hibernate.jpa.test.metamodel.Customer_; import org.hibernate.testing.SkipForDialect; +import org.hibernate.testing.TestForIssue; import org.junit.Test; /** @@ -116,6 +117,24 @@ public class ManipulationCriteriaTest extends AbstractMetamodelSpecificTest { em.getTransaction().rollback(); em.close(); } + + @Test + @TestForIssue(jiraKey = "HHH-8434") + public void basicMultipleAssignments() { + EntityManager em = getOrCreateEntityManager(); + em.getTransaction().begin(); + + CriteriaBuilder builder = em.getCriteriaBuilder(); + + CriteriaUpdate updateCriteria = builder.createCriteriaUpdate( Customer.class ); + updateCriteria.from( Customer.class ); + updateCriteria.set( Customer_.name, "Bob" ); + updateCriteria.set( Customer_.age, 99 ); + em.createQuery( updateCriteria ).executeUpdate(); + + em.getTransaction().commit(); + em.close(); + } @Test public void testJoinsAndFetchesDisallowed() {