HHH-10870 - Add test for issue

This commit is contained in:
Andrea Boriero 2016-06-20 18:27:22 +02:00
parent 69ee03a79c
commit c8acf1ed9e
1 changed files with 36 additions and 0 deletions

View File

@ -10,14 +10,19 @@ import javax.persistence.EntityManager;
import javax.persistence.Parameter;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Expression;
import javax.persistence.criteria.ParameterExpression;
import javax.persistence.criteria.Path;
import javax.persistence.criteria.Root;
import java.util.Arrays;
import org.junit.Test;
import org.hibernate.jpa.test.BaseEntityManagerFunctionalTestCase;
import org.hibernate.testing.TestForIssue;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
@ -114,6 +119,37 @@ public class ParameterTest extends BaseEntityManagerFunctionalTestCase {
em.close();
}
@Test
@TestForIssue(jiraKey = "HHH-10870")
public void testParameterInParameterList2() {
EntityManager em = getOrCreateEntityManager();
try {
em.getTransaction().begin();
final CriteriaQuery<MultiTypedBasicAttributesEntity> query = em.getCriteriaBuilder()
.createQuery( MultiTypedBasicAttributesEntity.class );
final Root<MultiTypedBasicAttributesEntity> root = query.from( MultiTypedBasicAttributesEntity.class );
root.get( "id" );
final ParameterExpression<Iterable> parameter = em.getCriteriaBuilder().parameter( Iterable.class );
root.in( new Expression[] {parameter} );
query.select( root );
final TypedQuery<MultiTypedBasicAttributesEntity> query1 = em.createQuery( query );
query1.setParameter( parameter, Arrays.asList( 1L, 2L, 3L ) );
query1.getResultList();
em.getTransaction().commit();
}
catch (Exception e) {
if ( em.getTransaction().isActive() ) {
em.getTransaction().rollback();
}
}
finally {
em.close();
}
}
@Override
public Class[] getAnnotatedClasses() {
return new Class[] { MultiTypedBasicAttributesEntity.class };