Minor query optimization
This commit is contained in:
parent
7bb8e850e8
commit
c636b3e6b4
|
@ -188,8 +188,8 @@ public class RepositoryDepositService {
|
||||||
//GK: Step two get it's doiEntity
|
//GK: Step two get it's doiEntity
|
||||||
CriteriaQuery<EntityDoiEntity> doiQuery = builder.createQuery(EntityDoiEntity.class);
|
CriteriaQuery<EntityDoiEntity> doiQuery = builder.createQuery(EntityDoiEntity.class);
|
||||||
Root<EntityDoiEntity> doiRoot = doiQuery.from(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.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)));
|
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();
|
List<EntityDoiEntity> dois = this.entityManager.createQuery(doiQuery).getResultList();
|
||||||
|
|
||||||
for(UUID uuid: dmpIds)
|
for(UUID uuid: dmpIds)
|
||||||
|
@ -197,7 +197,7 @@ public class RepositoryDepositService {
|
||||||
if (uuid.equals(currentId))
|
if (uuid.equals(currentId))
|
||||||
continue;
|
continue;
|
||||||
doiEntity = dois.stream()
|
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)
|
if (doiEntity != null)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue