Putting serializable classes in SQL?

Here's the situation. I have a bunch of objects that implement Serializable

that I want to store in a SQL database. I have two questions.

  • Is there a way to serialize the object directly to the database
  • Is this the best way to do it or should I
    1. Enter the object into formatting String

      and put it in the database that way and then parse it back
    2. Write to each member in the database a field that is unique for each object
+2


a source to share


3 answers


You can store objects directly with db4o:



http://www.db4o.com/Android/default.aspx

0


a source


It is generally not a good idea to try and put some kind of object (serialized / delimited) in your SQL because changing it is always a bitch.



Sounds like you are on the right track with Idea 2. Is this a one-to-many situation? (because then xref would obviously be the correct answer) or even a foreign key would be better. amuses.

+1


a source


I will still have a table for the class + a simplified DAO.
If you absolutely want to do it wrong :) then serialize to JSON and store the resulting string.

+1


a source







All Articles