GokhanAsilturk / bookPublisherProject_techCareerHomeWork

0 stars 0 forks source link

Code Refactoring #1

Open semihshn opened 1 year ago

semihshn commented 1 year ago

You shouldnt use @Autowired


image

semihshn commented 1 year ago

this instead of you should use CascadeType.REMOVE, in this way if author perma delete then also books of author delete with hibernate automatically


hint: you must write cascade=CascadeType.REMOVE to in @OneToMany annotation


image

semihshn commented 1 year ago

you should do something for 51. row to orElseThrow case and you should not invoke twice to authorRepository.findById also you should use getById method from same class because of clean code, we not want long method name in clean code


image

semihshn commented 1 year ago

image


Instead of using AUTHOR_MAPPER.convertToAuthorDto(this.authorEntityService.permanentlyDelete(id)), you can write this.authorEntityService.permanentlyDelete(id).convertTo(). Also, you can create a convertTo method inside the Author class like this;


image


image

semihshn commented 1 year ago

you should use .toList() instead of .collect(Collectors.toList())


image