简体   繁体   中英

How to save java serialized objects into database?

Now, I have 200k objects in java, each of which have an unique ID. I will access them randomly later. So I want to save these objects into a database. Which kind of database should be a good choice? The relational database(MySQL) or some NoSQL database?

I remember once working on a project where someone suggested that the ORM layer was unnecessary and over complicated the whole design.
He proposed that binary serializations should be written to a database table using the Object Id/Hash code, and a blob for the serialized object.

The problem that was pointed out with that approach occurs when the structure of a serialized Class changes, then all of the previously serialized object instancess need to be migrated/evolved.

So beware of storing a binary/serialized representation of an object for a long period of time.

最后,我使用Berkeley DB,这是一个嵌入式数据库,只能通过编程语言进行访问。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM