select e__ from org.hibernate.envers.test.entities.IntTestEntity_AUD e__ where e__.originalId.REV.id = (select max(e2__.originalId.REV.id) from org.hibernate.envers.test.entities.IntTestEntity_AUD e2__ where e2__.originalId.REV.id <= :revision and e__.originalId.id = e2__.originalId.id) and e__.REVTYPE <> :_p0 and e__.originalId.id = :_p1