HHH-8434 CriteriaUpdate with multiple assignments incorrect
This commit is contained in:
parent
ceead77b62
commit
10383fb4bb
|
@ -142,12 +142,12 @@ public class CriteriaUpdateImpl<T> extends AbstractManipulationCriteriaQuery<T>
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -117,6 +118,24 @@ public class ManipulationCriteriaTest extends AbstractMetamodelSpecificTest {
|
|||
em.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestForIssue(jiraKey = "HHH-8434")
|
||||
public void basicMultipleAssignments() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
em.getTransaction().begin();
|
||||
|
||||
CriteriaBuilder builder = em.getCriteriaBuilder();
|
||||
|
||||
CriteriaUpdate<Customer> 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() {
|
||||
EntityManager em = getOrCreateEntityManager();
|
||||
|
|
Loading…
Reference in New Issue