DTO implementation of Serializable interface

白昼怎懂夜的黑 提交于 2019-12-06 14:37:19

A DTO is normally a Data Transfer Object. It doesn't have to use Java Serialization, but if it doesn't it needs to follow some other convention.

Its not a matter of performance as if you are using Java Serialization it most likely has to be Serializable (or Externalizable which is still Serializable)

Not if you're not saving them to a file or sending them across a socket. There's nothing about a DTO that requires serialization. The need for serialization will depend on your planned usage. DTOs are generally created from a row in a result set returned by a database query. They are then passed back as the return value from a DAO call. From there they can be decorated or used as-is and consumed in whatever way your application requires. There's no requirement for them to be serializable.

DTOs are anemic in general and do not contain any business logic. DTOs are often java.io.Serializable - its only needed if you are going to transfer the data across JVMs.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!