returnem.createQuery("select r from RegistryEntity r where r.service.shortName = :ssn and r.registryStatus = :status and "
returnem.createQuery("select r from RegistryEntity r where r.service.shortName = :ssn and r.registryStatus = :status and r.registryStatus != :statusNot and "
+"r.agreedTime = (select max(r1.agreedTime) from RegistryEntity r1 where r1.user = r.user) and not exists "
+"(select r2 from RegistryEntity r2 where r2.user = r.user and r2.agreedTime > r.agreedTime)")