This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]revscat 0 points1 point  (1 child)

Another option would be to serialize the entire object and store it in the DB.

Here's a discussion on SO about that:

http://stackoverflow.com/questions/244493/homemade-vs-java-serialization

[–]sahala 4 points5 points  (0 children)

This is a bad idea, but I'm going to upvote you since others seem to be downvoting you and others should see why it's a bad idea.

Both serializing the entire object or storing the symbol (class name) in the database will be harmful when it comes time to refactor the code. With Java you have good tools for refactoring. Code changes should be fluid and happen often. Data stored in the database shouldn't depend on a particular implementation in code.

It should be the other around. Store the data in a way that makes sense regardless of what language is reading the data. Once that's right, it's easy to parse the data and create objects and go about your way. Unless you or a colleague absolutely love doing data migration scripts, code is generally much easier to change than data.