Homemade vs. Java Serialization

前端 未结 14 783
离开以前
离开以前 2021-02-04 06:16

I have a certain POJO which needs to be persisted on a database, current design specifies its field as a single string column, and adding additional fields to the table is not a

14条回答
  •  一个人的身影
    2021-02-04 06:30

    I'll second suggestion to use JAXB, or possibly XStream (former is faster, latter has more focus on object serialization part). Plus, I'll further suggest a decent JSON-based alternative, Jackson (http://jackson.codehaus.org/Tutorial), which can fully serializer/deserialize beans to JSON text to store in the column.

    Oh and I absolutely agree in that do not use Java binary serialization under any circumstances for long-term data storage. Same goes for Protocol Buffers; both are too fragile for this purpose (they are better for data transfer between tigtly coupled systems).

提交回复
热议问题