Due to codebase limitations out of my control, it's important that SQL data is only saved at the same time as everything else, so that even if a crash was to occur, all data would still be in sync with each other at the time it was saved, and no inconsistencies would arise.
I'd like to be able to use Hibernate or another ORM, but I'm concerned that I won't be able to control when data is saved to the DB, and that inconsistencies may arise.
Is there a way to control this? Would storing a session per each thread and calling save() on all when a save is scheduled work for this? I've read some posts that say Objects that have a representation in the DB are saved when modified.
Thank you.
What I needed was a Stateless Session this allows you to modify objects without changes being automatically saved without messing with flush modev
Plus, hibernate only automatically tracks changes while the specific session is open, which should never be used over any period of time anyway. Closing the session will cause the object to become attached, and a new session can be used to save it periodically.
Hope this helps someone in future!