I have a desktop java application that can be run by different users. It makes use of JPA to access a database that is stored as a file. For this purpose I do not want to run a separate database server.
The purpose of the database is to store actions that are done in the program, it's a simple "store record" operation. But all users must be able to read these stored records.
How can I make sure the different applications can save their actions, while not overwriting the actions of the other? So I need a way to:
- Open the database (file)
- Lock it
- Write the added action
- Close the database (file)
Is there a way in JPA to do/enforce this ? I'm now using hibernate, but that's not a strict requirement.
Please do not answer with "you can do this with technology XXX". Please note that I'm concerned with respect to the concurrency issues and how to enforce that the file is opened, and closed again. How can this be done with technology XXX ?