DEV Community

karim
karim

Posted on

java

 public void deleteStudent(Long studentId) {
        if(!studentRepository.existsById(studentId)) {
            throw new StudentNotFoundException(
                    "Student with id " + studentId + " does not exists");
        }
        studentRepository.deleteById(studentId);
    }
Enter fullscreen mode Exit fullscreen mode

Latest comments (0)