A JPA entity class leaks a lot of implementation detail, for example that 
you’re using JPA, what field maps to which database column, all sorts of mess. 
A good API type doesn’t make this sort of decision, the implementation should 
be free to use JPA, JDBC, Mongo, or whatever. 

This is why it’s usually a good idea to use clean DTOs for data transfer.

Best Regards,

Tim

> On 23 Jul 2018, at 14:03, Christian Schneider <[email protected]> wrote:
> 
> In very simple cases it is possible to transfer JPA entities but it is not a 
> good practice to do so.
> 
> For a remote service it makes sense to have a separate DTO. Often you can 
> also tailor the DTO to the use case of the remote service. Like in the 
> service facade pattern.
> 
> Christian
> 
> Am Mo., 23. Juli 2018 um 14:53 Uhr schrieb ceugster 
> <[email protected] <mailto:[email protected]>>:
> So if I get it right, I have theoretically two classes for Car, an entity Car
> and a DTO Car. Both have same fields and getters/setters. and as next step I
> use one class (instead of interface) car, that is used for both? Or is it
> better to separate each implementation (jpa entity and data transfer
> object)?
> 
> 
> 
> --
> Sent from: http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html 
> <http://karaf.922171.n3.nabble.com/Karaf-User-f930749.html>
> 
> 
> -- 
> -- 
> Christian Schneider
> http://www.liquid-reality.de <http://www.liquid-reality.de/>
> 
> Computer Scientist
> http://www.adobe.com <http://www.adobe.com/>
> 

Reply via email to