According to the docs of Spring HATEOAS
https://docs.spring.io/spring-hateoas/docs/0.25.3.BUILD-SNAPSHOT/reference/html/
it is clear that they want your DTO to inherit ResourceSupport.
But I find that a lot of my Models in the project has an id field. And that's a problem when extending ResourceSupport (which has a un-overidable getId method).
Now you might argue, your models should be separate from your DTO returned by REST anyway. Yes I find that, if those two things are exact same it's less maintenance to keep them to one class.
So what is the right design pattern?
(1) Change all my project models to rename id fields and thus doing a DB migration?
(2) Create DTOs matching every data model that extends ResourceSupport and then do object mapping before returning REST call?
Aucun commentaire:
Enregistrer un commentaire