Homemade vs. Java Serialization

前端 未结 14 939
离开以前
离开以前 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条回答
  •  萌比男神i
    2021-02-04 06:30

    How about the standard JavaBeans persistence mechanism:

    java.beans.XMLEncoder
    java.beans.XMLDecoder
    

    These are able to create Java POJOs from XML (which have been persisted to XML). From memory, it looks (something) like...

    
        
            Hello
            1
        
    
    

    You have to provide PersistenceDelegate classes so that it knows how to persist user-defined classes. Assuming you don't remove any public methods, it is resilient to schema changes.

提交回复
热议问题