Hibernate, online database and UPDATE
We are currently planning an application and are looking to use Hibernate. The database for the application will be an online one, but the application should be able to work in an offline mode. So, you can load an object from the database, close the connection, play around with the object and maybe later update it in the database. The problem now is that (well, as far as I k开发者_Python百科now) Hibernate performs an UPDATE on the database every timethe object is modified, meaning that it'd throw an exception if the connection was closed in the meantime. My question is now: can Hibernate be configured to perform updates at some manually specified time?
It looks like you don't completely understand the concept of Unit of Work used by Hibernate.
You can load the object in one session, then close the session and later merge that object (or another object with the same identity) into another session (so that modification of the object made in between will be flushed in that new session). In the meantime all sessions can be closed, and detached object can be used as a normal object (if you don't try to access its uninitialized lazy properties).
See also:
- 13.1. Session and transaction scopes
精彩评论