SCJP 1.4 - 63%
SCEA part I - 100% part II - ing
OCMJEA/SCEA, SCDJWS, SCBCD 1.3, SCJP 1.4
My SCEA experience:http://javalogue.blogspot.com/
OCMJEA/SCEA, SCDJWS, SCBCD 1.3, SCJP 1.4
My SCEA experience:http://javalogue.blogspot.com/
Rahul Mishra wrote:
Using DTO's is an anti pattern (anaemic domain model) .
Cameron Wallace McKenzie wrote:
Rahul Mishra wrote:
Using DTO's is an anti pattern (anaemic domain model) .
I couldn't agree more! It's frustrating to go into shops using JPA and EJB3, and see designs that build all these needless DTOs. Use your POJOs! That's what they are there for!
-Cameron McKenzie
SCJP 1.4 - 63%
SCEA part I - 100% part II - ing
Yi Chen wrote:
Do you mean that we could use JPA entities to transfer data across tiers?
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Regards,
VJ
SCJP 1.4, SCJP 6.0, SCWCD 1.4
the database table may change for some other requirement/reasons forcing our JPA entities to change.
Passing JPA Entities across layers is a good solution to trivial problems.
But then we don't design databases according to UI screen, do we?
suggesting that I pass JPA entities from these multiple tables (which no doubt are POJO's outside persistent context) to the presentation layer?
Besides client may not be interested in everything and we definitely do not want everything in the database table to be visible to the client.
but don't we create the TO's to reduce the network calls
Regards,
VJ
SCJP 1.4, SCJP 6.0, SCWCD 1.4
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
The collection won't load in web server. So we have to make sure that are loaded in EJB server before sending or avoid lazy loading
the database table may change for some other requirement/reasons forcing our JPA entities to change.
Passing JPA Entities across layers is a good solution to trivial problems.
But then we don't design databases according to UI screen, do we?
suggesting that I pass JPA entities from these multiple tables (which no doubt are POJO's outside persistent context) to the presentation layer?
Besides client may not be interested in everything and we definitely do not want everything in the database table to be visible to the client.
but don't we create the TO's to reduce the network calls
We have merge operation in JPA just for this purpose.Yi Chen wrote:Since JPA entities are POJO, do you think pass JPA entities instead of DTO across the tiers is a good practice?
For example: In presentation tier, we create a JPA entity object and set data into it with its setter. And then we pass this object to Session Facade as input parameter. Finally, Session Facade persistent the object into DB by EntityManager.
Your thoughts?