I need to get the difference between two set of integers (record ids). The first set is stored in text file, the second set is stored in mysql database. I have two options:
1- Read all ids from database, load them to java objects, load all ids from text file and use
Sets.difference(dbset, fileset);
2- Read only the text file ids and use a Hql query to get the difference:
public List getDiff(Set<Integer> ids){
Query query;
query = getSession().createQuery("from myset s where s.id not in (:ids)");
query.setParameterList("ids", ids);
return query.list();
}
I posted this question because these set can be quite big, and I don't know if is there any limits for Hibernate / Mysql query (Hibernate translate that query in "not in (1,2,3,...)) or otherwise, I can easily reach the jvm memory limit.