Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    Write you domain model following OOP principloes or/and DDD. Leverage business logic on domain model rules and make persistence just an abstraction. At the applicaiton level, write concrete persistence implementations but get rid of JPA and use a different ORM or mapper. For example MyBatis. This one allows you to presreve your domain model as is (encpasultaed data and behaviour), make it persistible and compatible with row mapping (from DB back to domain model), leaving the decision of implementing DTO only where they are needed... Usually controllers. Commented Oct 12, 2023 at 11:38
  • The kind of layered architectures you describe are caused most of the time by braindead implementions of opinionated frameworks and ORMs, leaving you with the feeling that there's no other way to implement applications in Java these days. It's, perhaps, the most productive and quicker one, but it's IMO, the one that sacrifices most of the good practices and principles we try to adere to Commented Oct 12, 2023 at 11:43