From: Radosław Smogura <rsmogura@softperience.eu>
To: Amar Dhole <adhole@tibco.com>
Cc: 'pgsql-jdbc@postgresql.org' <pgsql-jdbc@postgresql.org>
Subject: Re: use of savepoint in containter managed transaction
Date: Fri, 23 Sep 2011 15:58:42 +0200
Message-ID: <56e0d51a0da22ca7628aa2469cdeee8c@mail.softperience.eu> (raw)
In-Reply-To: <B056671652AA4D418763981054BCEAB4092DCD@PA-MBX04.na.tibco.com>
References: <B056671652AA4D418763981054BCEAB4092DCD@PA-MBX04.na.tibco.com>
I may suggest You, to try to manually use savepoints and rollbacks by
explicite specifying such queryies
createStatemnet().executeUpdate("SAVEPOINT ...")
createStatemnet().executeUpdate(ROLLBACK TO SAVEPOINT....)
createStatemnet().executeUpdate(RELEASE SAVEPOINT....)
but do not use COMMIT, nor ROLLBACK, nor PREPARE TRANSACTION.
You will need to put some work to arm your code in necessary try/catch.
If this will work, and consequences of this I don't know (I suppose at
80-90% that this should not affect XA, it's really hard to tell at eye
glance).
To your 1st topic
"Since it is managed transaction rollback not allowed" I couldn't find
itin JDBC source code, so I assume, JBoss wrapped driver. PG driver will
prohibit this behaviour too, but with different message.
Regards,
Radosław Smogura
http://softperience.eu
On Fri, 23 Sep 2011 13:19:53 +0000, Amar Dhole wrote:
> Hi,
>
> I have tried to use savepoint in jboss I got exception ,
> "Since it is managed transaction rollback not allowed"
> It will be great help how to avoid this error.
>
> 2) I have session bean where my transaction started it has assume 20
> insert in one table at 10th insert I get duplicate key exception what
> we do in our application increase key by catching exception and
> proceed ahead by in postgress when this exception occurs my all
> insert
> gets error out. So I thought to use savepoint or any other way to
> avoid this exception and proceed in my transaction.
>
> Thanks,
> Amar
>
> ----- Original Message -----
> From: Radosław Smogura [mailto:rsmogura@softperience.eu]
> Sent: Friday, September 23, 2011 04:54 AM
> To: Amar Dhole
> Cc: pgsql-jdbc@postgresql.org <pgsql-jdbc@postgresql.org>
> Subject: Re: [JDBC] use of savepoint in containter managed
> transaction
>
> On Fri, 23 Sep 2011 06:31:13 +0000, Amar Dhole wrote:
>> HI All,
>>
>> I have requirement to use save point. But I am using session bean
>> whose transaction is managed by container. While executing sql
>> insert
>> I got unique key constraint because of this my other command
>> following
>> this exception got ignored. I want to continue my transaction even
>> after this as we ignore this insert and make an entry in other table
>> for this error. And proceed head. with Postgres this is not
>> possible.
>> I cant user plsql block as behaviour is spread in all my
>> application.
>> Need some suggestion to achieve this with savepoint.
>>
>> I have some question.
>> 1) Can I use savepoint in Container Managed transaction ?
> Yes, You can, but I don't know result of this. ;) One day I worked on
> couple of patches, maybe I have those somewhere to acquire this what
> I
> assume You want.
>
>> 2) Can I make some custom change to jdbc driver to ignore duplicate
>> key exception or to raise warning instead ERROR.
> I assume, You want your transaction to proceed when error will occur.
> Yes you can make some change to ignore this, but this will not give
> you
> expected behaviour, because error is generated on server side, and
> server will rollback transaction.
>
> But please specify more details mainly what You want achieve and what
> are preconditions.
>> Thanks
>> Amar
>
> Regards,
> Radosław Smogura
> http://softperience.eu
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: rsmogura@softperience.eu, adhole@tibco.com
Subject: Re: use of savepoint in containter managed transaction
In-Reply-To: <56e0d51a0da22ca7628aa2469cdeee8c@mail.softperience.eu>
References: <B056671652AA4D418763981054BCEAB4092DCD@PA-MBX04.na.tibco.com> <56e0d51a0da22ca7628aa2469cdeee8c@mail.softperience.eu>
* 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