In the end I gave up implementing the JPA, because I do not want to mix
these two different approaches (Hibernate sessions and JPA).

So I have one questions: where do I find the HibernateSessionManager
implementation? It looks that I can't use regular
session.getTransaction().commit() becase it gives me *Transaction not
successfully started *error.

Here is my onFormSubmit method:

  public void onFormSubmit(Object observable, Object o) {
    Application application = (Application) o;
    applicationDao.save(application);

    if(!applicationDao.getSession().getTransaction().wasCommitted()) {
        applicationDao.getSession().getTransaction().commit();
        applicationDao.getSession().beginTransaction();
        log.info("Commiting the transaction!");
    } else {
        log.info("Do not commiting the transaction!");
    }

    caseId = application.getApplicationCase().getId();

    publisher.sendApplicationSubmittedMessage(user.getId(),
ipSource.getIpAddress(), caseId, application.getId());
  }

I have been reading about these (hibernate and tapestry) machanisms and it
looks that every thread has it's own session, which is being managed by
HibernateSessionManager. I am not pretty sure how to obtain that manager,
to safely commit the transaction.

Right now I am trying to get that manager and then call the commit.

2016-02-25 8:57 GMT+01:00 g kuczera <gkucz...@gmail.com>:

> But I think a JPA hook would be a better choice. The Interceptor hooks
>> happen for *all* the transactions in your SessionFactory, and JPA hooks are
>> more fine-grained.
>
> I am not really into JPA thing, but if I understand well I have to add the
> whole new configuration (in AppModule), as stated here:
> https://tapestry.apache.org/integrating-with-jpa.html
>
> All my classes are Daos and Dtos which uses the org,hibernate.Session (at
> least the Daos).
>
> 2016-02-24 23:55 GMT+01:00 Thiago H de Paula Figueiredo <
> thiag...@gmail.com>:
>
>> On Wed, 24 Feb 2016 19:33:13 -0300, g kuczera <gkucz...@gmail.com> wrote:
>>
>> I will try tomorrow the HibernateSessionManager.commit. But what do you
>>> think, guys, about Hibernate Interceptor? It has something similar to
>>> what Kalle mentioned, afterTransactionCompletion
>>> and beforeTransactionCompletion. Have you ever used it with Tapestry?
>>>
>>
>> The company I work uses it with Tapestry for some low-level stuff (mostly
>> setting modified date properties automatically and similar stuff). But I
>> think a JPA hook would be a better choice. The Interceptor hooks happen for
>> *all* the transactions in your SessionFactory, and JPA hooks are more
>> fine-grained.
>>
>>
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
>> For additional commands, e-mail: users-h...@tapestry.apache.org
>>
>>
>

Reply via email to