final OperationAllowedRepository operationAllowedRepository = context.getBean(OperationAllowedRepository.class);
Specifications<OperationAllowed> spec = Specifications.where(OperationAllowedSpecs.hasOperation(ReservedOperation.view));
for (Integer grpId : groups) {
spec = spec.and(OperationAllowedSpecs.hasGroupId(grpId));
}
final List<Integer> list = operationAllowedRepository.findAllIds(spec, OperationAllowedId_.metadataId);
final MetadataRepository metadataRepository = context.getBean(MetadataRepository.class);
Sort sortByChangeDateDesc = new Sort(Sort.Direction.DESC, Metadata_.dataInfo.getName()+"."+MetadataDataInfo_.changeDate);
Element result = metadataRepository.findAllAsXml(MetadataSpecs.hasMetadataIdIn(list), sortByChangeDateDesc);