From: Craig Ringer <ringerc@ringerc.id.au>
To: mephysto <mephystoonhell@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Postgres JDBC, WS and commit
Date: Mon, 21 May 2012 16:21:41 +0800
Message-ID: <4FB9FB15.3000406@ringerc.id.au> (raw)
In-Reply-To: <1336576000350-5697657.post@n5.nabble.com>
References: <1336576000350-5697657.post@n5.nabble.com>
On 05/09/2012 11:06 PM, mephysto wrote:
> Hi there,
> I'm using postgres-JDBC ina GlassFish application server to develop a web
> service application. I made several tries with either XA and standard
> driver. I use JDBC connection pool of GlassFish.
> I found that transaction started into a web service operation, are closed at
> the end of operation, not when in the code the connection are closed.
>
> I am searching a solution to close transaction that permit me to close
> trasaction when I want it, before end of web service operation.
>
> Is there a way to achieve this goal?
If you're using XA transactions in a Java EE context, what you want is
probably an EJB3 with
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
which will force the EJB business method(s) so annotated to run in their
own independent transactions. Note that these transactions will *NOT* be
able to see any uncommitted changes from your main transaction, they're
completely independent and behind the scenes with PostgreSQL are
actually new connections to the server.
--
Craig Ringer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: ringerc@ringerc.id.au, mephystoonhell@gmail.com
Subject: Re: Postgres JDBC, WS and commit
In-Reply-To: <4FB9FB15.3000406@ringerc.id.au>
References: <1336576000350-5697657.post@n5.nabble.com> <4FB9FB15.3000406@ringerc.id.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox