EntityTransaction txStream = emStream.getTransaction();
ScrollableResults metadataKeys = null;
txStream.begin();
try {
long currentTime = timeService.wallClockTime();
Session session = emStream.unwrap(Session.class);
Criteria criteria = session.createCriteria(MetadataEntity.class).setReadOnly(true)
.add(Restrictions.le(MetadataEntity.EXPIRATION, currentTime)).setProjection(Projections.id());
if (setFetchSizeMinInteger) {
criteria.setFetchSize(Integer.MIN_VALUE);
}