Intent To easily persist Java objects to the database.
Explanation Java serialization allow us to convert the object to a set of bytes. We can store these bytes into database as BLOB(binary long objects) and read them at any time and reconstruct them into Java objects.
Programmatic Example
Walking through our customers example, here’s the basic Customer entity.
1@Getter 2@Setter 3@EqualsAndHashCode 4@ToString 5@AllArgsConstructor 6public class Country implements Serializable { 7 8 private int code; 9 private String name; 10 private String continents; 11 private String language; 12 public static final long serialVersionUID = 7149851; 13 // Constructor -> 14 // getters and setters -> 15} Here is CountrySchemaSql, this class have method allow us to serialize Country object and insert it into the database, also have a method that read serialized data from the database and deserialize it to Country object.