Java Hibernate Help

Discussion in 'Programming' started by cris02, Aug 14, 2013.

  1. #1
    Hello,

    Is there a work around to fix this kind of error

    I have criteria query like this

    
    Criteria criteria = session.createCriteria(blog.class);
    criteria.add(Restrictions.in("id", id_list));
    blogs = criteria.list();
    
    Code (markup):
    id_list is large list of ids that i want to query in another table. Unfotunately it doesnt work if the value of id_list is more than 2000. I get this error:

    Prepared or callable statement has more than 2000 parameter markers.
    Code (markup):
    Anyone have idea? Please help. THanks
     
    cris02, Aug 14, 2013 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    Unfortunately you are stuck at that limit. There are many workarounds you can use including:
    • Creating temp tables (if that's an option), store those ids there and subquery the results that way.
    • Use lists of lists to store a count of <2000 items and query each list on its own then combine the data, sample code here.
     
    ThePHPMaster, Aug 14, 2013 IP