Is it wrong to use object objects in all layers of a web application?

I am developing a web application using a tiered architecture. I have:

  • Application level (controllers)
  • Service Level
  • Data Access Level (DAO)

which connects to the Oracle database.

I am using JPA with Hibernate as an implementation. Therefore, I create entities to model the representation of objects in my relational database tables.

My question is ... Is it a bad practice to use these objects objects in all three of my layers?

I know that it should be used according to the level of access to data, at least, but what is further than at the level of service and application?

I saw that some people use DTOs in the service and application layers, and they convert between DTOs and objects between the Service and Data Access layers.

Just wondering what is best for this and what should be the best approach?

+4
source share
2 answers

You should never use entity objects at all levels. Using the same object throughout the layer, you perform a tight relationship between the data in the user interface form and the database tables.

, . , DTOs, VO DAO . , . orika mapper.

+1

, , . , , , / -. .

/ . , , . , - . , , - .

. , , JSON (*), ( ) . , JSP.

(*) , , () . - , , .

+3

Source: https://habr.com/ru/post/1599668/


All Articles