X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 4CA169F9C10 for ; Thu, 4 May 2006 13:35:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 85165-02 for ; Thu, 4 May 2006 13:35:36 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by postgresql.org (Postfix) with ESMTP id E55119F9B76 for ; Thu, 4 May 2006 13:35:34 -0300 (ADT) Received: from 221x253x225x162.ap221.ftth.ucom.ne.jp ([221.253.225.162] helo=[192.168.1.171]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1Fbgnb-0000ye-Pm; Fri, 05 May 2006 04:35:31 +1200 Message-ID: <445A2D4F.9070403@opencloud.com> Date: Fri, 05 May 2006 01:35:27 +0900 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.7 (Windows/20050923) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Martina CC: pgsql-jdbc@postgresql.org Subject: Re: Transaction foreign key violation References: <4459FE02.6020606@mpiib-berlin.mpg.de> In-Reply-To: <4459FE02.6020606@mpiib-berlin.mpg.de> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200605/9 X-Sequence-Number: 15137 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