pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: Martina <boehme@mpiib-berlin.mpg.de>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Transaction foreign key violation
Date: Fri, 05 May 2006 01:35:27 +0900
Message-ID: <445A2D4F.9070403@opencloud.com> (raw)
In-Reply-To: <4459FE02.6020606@mpiib-berlin.mpg.de>
References: <4459FE02.6020606@mpiib-berlin.mpg.de>

Martina wrote:
> 
> I'm getting a foreign key constraint violation if I run a transaction in 
> which the first statement inserts a new row in Table1 (with serial as 
> pk, "idTable1") and the second statement gets this "idTable1" as a fk. 
> Because it is not there yet (but in the same transaction) I get this 
> error. If I don't use transaction it is working.
> What can I do?

Can you show us your code, or (better) a small testcase that shows the 
problem?

> I tried "SET 
> TRANSACTION ISOLATION LEVEL SERIALIZABLE" (just with query.execute() 
> before the other statements)) - no luck. 

The right way to do this is via Connection.setTransactionIsolation().

-O



view thread (2+ messages)

Message-ID: <445A2D4F.9070403@opencloud.com>
Permalink:  ../445A2D4F.9070403@opencloud.com/
Also on:    postgresql.org/message-id/445A2D4F.9070403@opencloud.com

 · 

reply

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: oliver@opencloud.com, boehme@mpiib-berlin.mpg.de
  Subject: Re: Transaction foreign key violation
  In-Reply-To: <445A2D4F.9070403@opencloud.com>
  References: <4459FE02.6020606@mpiib-berlin.mpg.de> <445A2D4F.9070403@opencloud.com>

* 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