4 Replies Latest reply on Apr 21, 2009 10:53 PM by gonorrhea

    Writing changes to DB while still at transaction - how?

    alex_krasov

      Hi.


      I've got a problem that I still can't solve while putting too much effort for it, so may be you can help :)


      My component have 3 methods: start(), proceed() and finish();


      start() annotated as @Begin, finish() annotated as @End. Both are @Transactional
      They do stuff with JPA such as creating a new entities and updating existing ones.
      Changes are actually written to DB on transaction commit, i.e. when finish() ends.
      Till now everything good.


      Now I have a requirement that in some case while at proceed(), my entity will be immediately persisted to db no matter what when running entityManager.persist
      How can I do it? Manually executing entityManager.flush() doesn't helps at all, playing with its FlushMode doesn't helps either.
      Is it possible to begin some kind of nested isolated transaction before persisting and commit it after persisting?



      Thanks a lot,
      Alex.