Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 2A13E1337B47 for ; Thu, 31 Mar 2011 11:35:26 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 14181-03 for ; Thu, 31 Mar 2011 14:35:17 +0000 (UTC) X-Greylist: delayed 00:15:30.185029 by SQLgrey-1.7.6 Received: from cpanelsmarthost1.zen.co.uk (cpanelsmarthost1.zen.co.uk [82.71.204.225]) by mail.postgresql.org (Postfix) with ESMTP id 7BC401337B2F for ; Thu, 31 Mar 2011 11:35:15 -0300 (ADT) Received: from [88.98.24.71] (helo=shcp03.hosting.zen.net.uk) by cpanelsmarthost1.zen.co.uk with esmtp (Exim 4.69) (envelope-from ) id 1Q5Iit-0001ga-Fk for pgsql-jdbc@postgresql.org; Thu, 31 Mar 2011 14:19:43 +0000 Received: from [212.135.39.2] (helo=[62.185.32.149]) by shcp03.hosting.zen.net.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Q5Iin-0003cf-7s for pgsql-jdbc@postgresql.org; Thu, 31 Mar 2011 15:19:37 +0100 Message-ID: <4D948DA4.3070901@ahastie.net> Date: Thu, 31 Mar 2011 15:20:20 +0100 From: Andrew Hastie User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.14) Gecko/20110223 Lightning/1.0b2 Thunderbird/3.1.8 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re-read of updated row using scrollable ResultSet returns old data Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - shcp03.hosting.zen.net.uk X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - ahastie.net X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201103/152 X-Sequence-Number: 21707 It appears that the PG driver returns the original rather than the updated data values for an updatable ResultSet. This is where the updates are applied to a single table ResultSet in a single transaction. The following scenario illustrates: 1. Set Auto Commit off and start a new transaction 2. Create a ResultSet based upon a query on a single table. The target table has a primary key, and the ResultSet is created as type ResultSet.TYPE_SCROLL_SENSITIVE and ResultSet.CONCUR_UPDATABLE 3. Position to a specific row via ResultSet.absolute(n) (where n = row ordinal) 4. Update a column value via ResultSet.updateX(colName,value) 5. "Flush" the update via ResultSet.updateRow() 6. Position to a different row 7. Position back to the same row as updated in steps 3-5 8. Read in the column value for the updated column Observe that with the Postgres driver you always get the original data value back and never the new value. This appears to conflict with the JDBC Specification which states:- ======================== JDBC4 Specification 15.2.4.1: "The method DatabaseMetaData.ownUpdatesAreVisible(int type) returns true if a ResultSet object of the specified type is able to see its own updates and returns false otherwise." ======================== I've tried the above scenario out on a variety of other database platforms (MS SQLServer, IBM DB2) and these definitely return you the updated data values on a subsequent re-read. The behavior also conflicts with the Database connection meta-data returned as follows:- INFO - Own updates visible for TYPE_SCROLL_INSENSITIVE = true INFO - Other updates visible for TYPE_SCROLL_INSENSITIVE = false INFO - Own updates visible for TYPE_SCROLL_SENSITIVE = true INFO - Other updates visible for TYPE_SCROLL_SENSITIVE = false INFO - Updates detected for TYPE_SCROLL_INSENSITIVE = false INFO - Updates detected for TYPE_SCROLL_SENSITIVE = false If however you applied the row update using an SQL UPDATE on a separate Statement as opposed to using the ResultSet.updateX() methods within the same transaction, then you DO see the new value at step 8. I suggest both techniques should yield the same results. This is a real pain as I don't see how you can keep track of changes made whilst scrolling up and down a table if you want to use the ResultSet.updateX() methods. This linked with the restriction with the Postgres driver that a table MUST have a Primary Key in order for this technique to work, makes life difficult. Behaviour observed with:- JDBC Driver Version: PostgreSQL 9.0devel JDBC4 (build 800) Server version: 8.4.7