I was thinking of implementing a file based persistent store in Java. I can write the contents of the Objects to a file on the disk. I can dump 100 objects (e.g., for 100 employees) to a file. However how do I read one of the object (for a particular employee) back?
For example if I want to change the data for an object, how can I retrieve the object and replace it in the file.
I hope my question makes sense. In terms of databse terms, Create is fine, but how do I perform Read/Update/Delete?
Couple of options that comes to my mind are:
- create a different file for each object
- retrieve the data for all objects, deserialize them and subsequently persist them again after performing the relevant operations
But both of them are not efficient and have drawbacks.
I hope my question makes sense. Will be thankful for any suggestions/pointers.