T
tnorgd
Dear Group,
I have a bunch of classes (say, 5-10) that I would like to serialize
into an SQL database. I decided to implement this on my own, because:
- I need to keep control over the data; not all the fields from a
class need to go into DB
- the DB storage format must be easy for humans who are browsing the
DB; there are also scripts in R for data analysis that will read from
the DB
- Stuff like Hibernate is a too heavy gun for it;
My original idea was to add a constructor initialized with SQL
connection, or a pair of static methods for reading from / writing to
a DB into each of my classes. I also plan to use an existing package
to facilitate SQL query building.
In general, I have three goals:
- write my own code that:
- will store the data in the format I need,
- spending as short time on it as necessary
Can you share some advices or some parts of working code for some
inspiration?
Tim
PS. Another issue with it is that my data comes from experiments and
each observation (rather than an object) is unique. What I mean is
that (as I understand) in typical persistence approach each Java
object can be serialized / deserialized as a unique entity. In my case
each row of data is unique and DB must store exactly one copy of it,
no matter how many objects keep this data. Luckily I have a way to
annotate the rows (e.g time stamp or measurementID)
I have a bunch of classes (say, 5-10) that I would like to serialize
into an SQL database. I decided to implement this on my own, because:
- I need to keep control over the data; not all the fields from a
class need to go into DB
- the DB storage format must be easy for humans who are browsing the
DB; there are also scripts in R for data analysis that will read from
the DB
- Stuff like Hibernate is a too heavy gun for it;
My original idea was to add a constructor initialized with SQL
connection, or a pair of static methods for reading from / writing to
a DB into each of my classes. I also plan to use an existing package
to facilitate SQL query building.
In general, I have three goals:
- write my own code that:
- will store the data in the format I need,
- spending as short time on it as necessary
Can you share some advices or some parts of working code for some
inspiration?
Tim
PS. Another issue with it is that my data comes from experiments and
each observation (rather than an object) is unique. What I mean is
that (as I understand) in typical persistence approach each Java
object can be serialized / deserialized as a unique entity. In my case
each row of data is unique and DB must store exactly one copy of it,
no matter how many objects keep this data. Luckily I have a way to
annotate the rows (e.g time stamp or measurementID)