Skip to content
Snippets Groups Projects
Commit d5dfe5d7 authored by felmer's avatar felmer
Browse files

LMS-2854 problem was that more than 32767 deleted samples are in the system....

LMS-2854 problem was that more than 32767 deleted samples are in the system. In the SQL statement the 'in (..)' part has therefore more parameters than allowed. Problem is solved by get not more than 30k in one go.

SVN: 24749
parent 139b1db0
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@
package ch.systemsx.cisd.openbis.generic.server.dataaccess.db;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
......@@ -448,10 +449,23 @@ final class DeletionDAO extends AbstractGenericEntityDAO<DeletionPE> implements
{
return Collections.emptyList();
}
DetachedCriteria criteria = DetachedCriteria.forClass(entityKind.getDeletedEntityClass());
HibernateTemplate hibernateTemplate = getHibernateTemplate();
List<Long> ids = TechId.asLongs(entityIds);
criteria.add(Restrictions.in(ID, ids));
return cast(getHibernateTemplate().findByCriteria(criteria));
int chunkSize = 30000;
List<IDeletablePE> result = new ArrayList<IDeletablePE>();
for (int i = 0, n = ids.size(); i < n; i += chunkSize)
{
DetachedCriteria criteria =
DetachedCriteria.forClass(entityKind.getDeletedEntityClass());
List<Long> subList = ids.subList(i, Math.min(n, i + chunkSize));
if (subList.isEmpty() == false)
{
criteria.add(Restrictions.in(ID, subList));
List<IDeletablePE> list = cast(hibernateTemplate.findByCriteria(criteria));
result.addAll(list);
}
}
return result;
}
public List<TechId> listDeletedEntitiesForType(EntityKind entityKind, TechId entityTypeId)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment