use of org.hibernate.testing.transaction.TransactionUtil2.inTransaction in project hibernate-orm by hibernate.
the class JPAQLComplianceTest method testParameterCollectionParenthesesAndPositional.
@Test
@TestForIssue(jiraKey = "HHH-12290")
public void testParameterCollectionParenthesesAndPositional() {
final Item item = new Item("Mouse");
item.setId(1L);
final Item item2 = new Item("Computer");
item2.setId(2L);
TransactionUtil2.inTransaction(sessionFactory(), s -> {
s.save(item);
s.save(item2);
});
TransactionUtil2.inTransaction(sessionFactory(), s -> {
Query q = s.createQuery("select item from Item item where item.id in(?1) and item.name in (?2) and item.id in(?1)");
List<Long> idParams = new ArrayList<>();
idParams.add(item.getId());
idParams.add(item2.getId());
q.setParameter(1, idParams);
List<String> nameParams = new ArrayList<>();
nameParams.add(item.getName());
nameParams.add(item2.getName());
q.setParameter(2, nameParams);
List result = q.getResultList();
assertNotNull(result);
assertEquals(2, result.size());
});
TransactionUtil2.inTransaction(sessionFactory(), s -> s.createQuery("from Item").list().forEach(result -> s.delete(result)));
}
Aggregations