query.append(LFFileStorageModelImpl.ORDER_BY_JPQL);
}
String sql = query.toString();
Query q = session.createQuery(sql);
q.setFirstResult(0);
q.setMaxResults(2);
QueryPos qPos = QueryPos.getInstance(q);
if (bindFilename) {
if (filename != null) {
qPos.add(filename);
}
}
if (orderByComparator != null) {
Object[] values = orderByComparator.getOrderByConditionValues(lfFileStorage);
for (Object value : values) {
qPos.add(value);
}
}
List<LFFileStorage> list = q.list();
if (list.size() == 2) {
return list.get(1);
} else {
return null;