I'm working on Seam project and have following problem - there is an ajax edit form and many interactions with this form affect (mutate) underlying entity and are changed in db immediately, but I wan't those changes persisted in database only when user will press "save" button. I'm thinking about deataching entity to accomplish this but wonder how (Also looking for smarter solutions).
Asked
Active
Viewed 321 times
1 Answers
3
The changes that you are making to an entity are immediately reflected making it synchronized with database. To detach a entity, you can use entityManager.detach(object)
or entityManager.clear()
, but that will detach all managed entities.
EntityManager's flush-mode is FlushModeType.AUTO
by default, instead try FlushModeType.COMMIT
in which changes are flushed only on explicit commit/flush & then using entityManager.flush()
to synchronize the persistence context to the underlying database.

Nayan Wadekar
- 11,444
- 4
- 50
- 73
-
entityManager.detach(object) is maybe a cool thing but is available since java 6, my project uses java 5. – Jeriho May 11 '11 at 09:06
-
Try managing transactions manually(BMT), rather then using CMT, so you will be able to persist entity when required after making changes. – Nayan Wadekar May 11 '11 at 16:52