0

我正在使用 Netbeans 12.4,尽管我在编译时声明了异常,但由于某种原因我收到以下错误:

必须捕获或声明抛出未报告的异常 DoesNotExistsException

@Override
    public void deleteB(Long bId) throws DoesNotExistsException {
 
    B b = em.find(B.class, bId);
    em.remove(b);
    
    A mandatoryA = new A();
    mandatoryA.getBs().stream().map(bInSet -> bInSet.getA().orElseThrow(() -> new DoesNotExistsException("Mandatory A does not exist!"))) 
            .filter(a -> a.getCurrentB().equals(b))
            .forEach(a -> a.setCurrentB(null));

}

编辑:DoesNotExistsException 只是扩展了 Exception

4

0 回答 0