Hi there, there’s a part in this code that I don’t understand why it had to be done that way.
In the src/main/java/io/educative/mediaapp/service/PlaylistService.java
class, the method deletePlaylist
confused me.
public void deletePlaylist(BigInteger playlistId) {
Playlist playlist = getPlaylist(playlistId);
playlist.setId(playlistId);
playlistRepo.delete(playlist);
}
Here, why do we have to get a Playlist with the given Id and then set the Id of the found Playlist to that given Id again? Why can’t we skip line 3, which is playlist.setId(playlistId);
?
I hope to get some clarification. I really appreciate any help you can provide.
-Ginny
Course: Developing Microservices with Spring Boot - Learn Interactively
Lesson: Your First App: Media Playlist - Developing Microservices with Spring Boot