Is it problematic that Spring Data REST exposes entities via REST resources without using DTOs?

前端 未结 3 1852
说谎
说谎 2021-01-30 02:47

In my limited experience, I\'ve been told repeatedly that you should not pass around entities to the front end or via rest, but instead to use a DTO.

Doesn\'t Spring Dat

3条回答
  •  离开以前
    2021-01-30 03:15

    Spring Data REST enables a very fast way to prototype and create a REST API based on a database structure. We're talking about minutes vs days, when comparing with other programming technologies.

    The price you pay for that, is that your REST API is tightly coupled to your database structure. Sometimes, that's a big problem. Sometimes it's not. It depends basically on the quality of your database design and your ability to change it to suit the API user needs.

    In short, I consider Spring Data REST as a tool that can save you a lot of time under certain special circumstances. Not as a silver bullet that can be applied to any problem.

提交回复
热议问题