vendredi 25 septembre 2020

Data conversion pattern with Business Object, DTO and Entity/Domain Object

In my Spring boot project I use hibernate and basically we have three kinds of objects

  • DTO object which is used in the controller layer.
  • Business Object - business object is what we use throughout our application.
  • Entity/Domain Object - which is used in JPA layer.

When we are ready to save the data we turn the Business Object to Domain/Entity Obj

And when we are ready to send it to the client/controller we can convert the entity object to Business Obj and this Business object in turn to DTO Obj.

Ideally I was told that the conversion logic of changing BOs to -> (DTOs and entities) and vice versa reside in the BOs itself?

How do we achieve this in an efficient way? Can anyone help with any examples?

Aucun commentaire:

Enregistrer un commentaire