The idea with @CommitAfter is that Tapestry is responsible for handling the
transaction, using the session-in-view pattern. The session is created
lazily, when first needed. The transaction for the session is committed at
the end of a method with @CommitAfter. The session is available to be
injected using the plain @Inject annotation.

Some notes:

@CommitAfter works with no additional work on methods of pages and
components, but takes some extra configuration when used with services (see
the bottom of http://tapestry.apache.org/hibernate-user-guide.html).

@CommitAfter does not nest, though that may change in 5.4.

Tapestry's built-in Hibernate support only supports a single database; if
you are doing something more complicated (and I really must say: do you
really want to?  Can you break things apart using a web service or JMS
instead, but I digress) ... well, you are on your own.

Finally, that Session object injected is a global proxy that delegates to
the a per-thread instance, so don't worry about concurrency.  In the world
of servlets, per-thread and per-request are effectively synonymous.


On Thu, Nov 29, 2012 at 10:36 AM, Thiago H de Paula Figueiredo <
thiag...@gmail.com> wrote:

> On Wed, 28 Nov 2012 22:28:58 -0200, Pillar <sotodel...@hotmail.com> wrote:
>
>  Ok, so I didn't know that, I thought SessionFactory was a singleton.
>>
>
> It never was. If you're connecting to two different databases, you'll need
> a SessionFactory for each.
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org>
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

Reply via email to