protected void validateOkToDelete(List<DeleteConflict> theDeleteConflicts, ResourceTable theEntity, boolean theForValidate) { TypedQuery<ResourceLink> query = myEntityManager.createQuery("SELECT l FROM ResourceLink l WHERE l.myTargetResourcePid = :target_pid", ResourceLink.class); query.setParameter("target_pid", theEntity.getId()); query.setMaxResults(1); List<ResourceLink> resultList = query.getResultList(); if (resultList.isEmpty()) { return; } if (myDaoConfig.isEnforceReferentialIntegrityOnDelete() == false && !theForValidate) { ourLog.debug("Deleting {} resource dependencies which can no longer be satisfied", resultList.size()); myResourceLinkDao.deleteAll(resultList); return; } ResourceLink link = resultList.get(0); IdDt targetId = theEntity.getIdDt(); IdDt sourceId = link.getSourceResource().getIdDt(); String sourcePath = link.getSourcePath(); theDeleteConflicts.add(new DeleteConflict(sourceId, sourcePath, targetId)); }
protected void validateOkToDelete(List<DeleteConflict> theDeleteConflicts, ResourceTable theEntity, boolean theForValidate) { TypedQuery<ResourceLink> query = myEntityManager.createQuery("SELECT l FROM ResourceLink l WHERE l.myTargetResourcePid = :target_pid", ResourceLink.class); query.setParameter("target_pid", theEntity.getId()); query.setMaxResults(1); List<ResourceLink> resultList = query.getResultList(); if (resultList.isEmpty()) { return; } if (myDaoConfig.isEnforceReferentialIntegrityOnDelete() == false && !theForValidate) { ourLog.debug("Deleting {} resource dependencies which can no longer be satisfied", resultList.size()); myResourceLinkDao.deleteAll(resultList); return; } ResourceLink link = resultList.get(0); IdDt targetId = theEntity.getIdDt(); IdDt sourceId = link.getSourceResource().getIdDt(); String sourcePath = link.getSourcePath(); theDeleteConflicts.add(new DeleteConflict(sourceId, sourcePath, targetId)); }