Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate createNativeQuery using IN clause

Using Java, Hibernate.

I have a query

String pixIds = "1,2,3";
String query = "SELECT * FROM comment WHERE PIX_ID IN (:pixIds)";
q.setParameter("pixIds", pixIds);
List<Object[]> results =  q.getResultList();

I'm not able to bind this parameter to pixIds using the code above. What is the right way to do this?

Note : the query I have here is a simplified version of my actual query.

like image 528
smahesh Avatar asked Apr 15 '26 10:04

smahesh


1 Answers

The following method works
public Query setParameterList(String name, Collection vals) throws HibernateException

like image 118
smahesh Avatar answered Apr 17 '26 23:04

smahesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!