Serialized Entity Pattern
To easily persist Java objects to the database.
- Data object
An object representing some data that we want to store.
Uses Java object serialization to translate the object into a set of bytes.
- Database table
Stores the set of bytes.
The client passes a data object to a DAO. The DAO uses Java object serialization to translate the object into a set of bytes, which are stored directly in the database. When the client needs to retrieve the object, the DAO reads the bytes back from the database and reconstitutes the object.
Using serialization has two major drawbacks: the data cannot be queried directly in the database, and the data must be converted if the structure of the underlying objects changes. Using objects that can write themselves to XML alleviates both these concerns.