0

0I have this method:

public List<Product> getProductsByListIds(List<Long> ids) {
    String query = "from Product pr where pr.id in(:ids)";
    List<Product> products= (List<Product>) getSession().createQuery(query)
        .setParameterList("ids", ids).list();
    return products;
  }

This method is OK, my only problem is when the ids.size() >1000 I'm trying to find a convincing solution to this problem.

senior
  • 2,066
  • 6
  • 34
  • 53

1 Answers1

0

My advice would be to take a step back and look at the design and what you're trying to achieve, passing hundreds of parameters into an SQL statement is not going to be very efficient and I'd be surprised if it's the most elegant solution to your requirement.

Without knowing more about how this method is called and where this list of ids comes from it's difficult to give concrete advice, however I would recommend that you look into using joins if possible.

StuPointerException
  • 6,877
  • 2
  • 28
  • 53