users@jersey.java.net

Re: AW: [Jersey] Database Transactions with Jersey

From: Paul Sandoz <Paul.Sandoz_at_oracle.com>
Date: Thu, 12 Aug 2010 10:30:01 +0200

On Aug 11, 2010, at 10:42 PM, Christian Helmbold wrote:

>
>
>> I think if you are using Guice already the AOP approach may be a nice
>> solution.
>>
>> You need to be careful of the case of handling lazy DB access.
>> Sometimes the
>> serialization of the entity requires access to DB stuff (e.g. JPA
>> beans) so the
>> transaction needs to be kept open until the response entity has
>> been fully
>> serialized.
>
> What comes after entity serialization?

 From the Jersey perspective once entity serialization has occurred it
does some life-cycle management of Jersey managed resources (e.g.
calling @PostConstruct, if present, onf per-request managed resources)
then hands control back to the servlet.

Paul.

> More specific: when to close the
> transaction if not outside of the JAX-RS application (within a
> Servlet filter)?
>

> For now I use a Servlet filter and it seems to work. But I fear that
> there could
> be a performance impact when the server is under heavy load, because
> of started
> but not needed transactions. On the other hand this is the default
> configuration
> for Wicket applications as far as I know and it seems to work in
> production
> environments.
>
> Christian
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>