On Wed, Feb 24, 2016 at 12:27 PM, g kuczera <gkucz...@gmail.com> wrote:

> Sorry for not editing the post properly, I accidentally sent it by pressing
> the space few times (first time using the fullscreen editing on gmail).
>
> So, the question is if the hibernate Interceptor is the way to go? Do you
> have any other idea how to be 100% sure that my method from observer will
> be called after committing the changes?
>

The obvious choice is to manually commit the transaction, then notify the
observers. @CommitAfter is fine for simple cases but if the transaction is
rolled back, it doesn't allow you to react to it. If you still prefer
annotation, you could try out
https://github.com/satago/tapestry-jpa-transactions that support pre/after
commit hooks.

Kalle



> 2016-02-24 21:23 GMT+01:00 g kuczera <gkucz...@gmail.com>:
>
> > Hi guys,
> > I embedded the ApplicationSubmitForm (component) in my Page. If it is
> > successfully validated, the onSuccessFromNewApplicationForm method is
> > called:
> >
> > private Set<FormSubmitObserver> observers;
> >
> >   @CommitAfter
> >   public void onSuccessFromNewApplicationForm() {
> >
> >     Application application = new Application();
> >     application.setStatus(/* some value */);
> >     application.setRegistrationDate(new Date());
> >
> >     notifyObservers(application, true);
> >   }
> >
> > One of the observers - there is a field *observers*, which is a set -
> > sends an event to the mailing server. In 99% cases it works fine, but
> > sometimes the second application (on the different server), while
> checking
> > if an application indicated by the given id exists, does not find the
> > record. There is nothing like that in the database yet.
> >
> > It looks that the above module is badly designed. It does not matter that
> > there is the CommitAfter annotation, if I call the methods which assume
> > that everything is commited from within the commiting method.
> >
> > Am I right?
> >
> >
> >
>

Reply via email to