Minor query optimization

This commit is contained in:
George Kalampokis 2023-11-03 18:00:06 +02:00
parent 7bb8e850e8
commit c636b3e6b4
1 changed files with 3 additions and 3 deletions

View File

@ -188,8 +188,8 @@ public class RepositoryDepositService {
//GK: Step two get it's doiEntity
CriteriaQuery<EntityDoiEntity> doiQuery = builder.createQuery(EntityDoiEntity.class);
Root<EntityDoiEntity> doiRoot = doiQuery.from(EntityDoiEntity.class);
doiQuery = doiQuery.multiselect(doiRoot.get("entityId").get("id"), doiRoot.get("doi"), doiRoot.get("repositoryId"));
doiQuery = doiQuery.where(builder.and(doiRoot.get("entityId").get("id").in(dmpIds), builder.equal(doiRoot.get("isActive"), IsActive.Active)));
doiQuery = doiQuery.multiselect(doiRoot.get("entityId").get("id"), doiRoot.get("doi"));
doiQuery = doiQuery.where(builder.and(doiRoot.get("entityId").get("id").in(dmpIds), builder.equal(doiRoot.get("isActive"), IsActive.Active), builder.equal(doiRoot.get("repositoryId"), repoId)));
List<EntityDoiEntity> dois = this.entityManager.createQuery(doiQuery).getResultList();
for(UUID uuid: dmpIds)
@ -197,7 +197,7 @@ public class RepositoryDepositService {
if (uuid.equals(currentId))
continue;
doiEntity = dois.stream()
.filter(entityDoiEntity -> entityDoiEntity.getEntityId().getId().equals(uuid) && entityDoiEntity.getRepositoryId().equals(repoId)).findFirst().orElse(null);
.filter(entityDoiEntity -> entityDoiEntity.getEntityId().getId().equals(uuid)).findFirst().orElse(null);
if (doiEntity != null)
break;
}