Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 14331 invoked from network); 27 Sep 2006 16:11:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 27 Sep 2006 16:11:23 -0000 Received: (qmail 37514 invoked by uid 500); 27 Sep 2006 16:11:22 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 37293 invoked by uid 500); 27 Sep 2006 16:11:22 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 37284 invoked by uid 99); 27 Sep 2006 16:11:22 -0000 Received: from idunn.apache.osuosl.org (HELO idunn.apache.osuosl.org) (140.211.166.84) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 27 Sep 2006 09:11:22 -0700 Authentication-Results: idunn.apache.osuosl.org smtp.mail=dremesh@gmail.com; spf=pass Authentication-Results: idunn.apache.osuosl.org header.from=dremesh@gmail.com; domainkeys=good X-ASF-Spam-Status: No, hits=0.8 required=5.0 tests=DNS_FROM_RFC_ABUSE,MAILTO_TO_SPAM_ADDR Received-SPF: pass (idunn.apache.osuosl.org: domain gmail.com designates 66.249.82.230 as permitted sender) DomainKey-Status: good X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 Received: from [66.249.82.230] ([66.249.82.230:4254] helo=wx-out-0506.google.com) by idunn.apache.osuosl.org (ecelerity 2.1.1.8 r(12930)) with ESMTP id 90/40-29243-6A2AA154 for ; Wed, 27 Sep 2006 09:11:19 -0700 Received: by wx-out-0506.google.com with SMTP id i27so248156wxd for ; Wed, 27 Sep 2006 09:11:16 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=acCB95ag3rx5b040dhzJW9v8jmvMzRFYy6K1XA8OqOjvfxl3vkwaiZAqb5z3vef+M4BpgsNS1I8D+7o//hQ5Y/4Uj2RBU5wZ0ImMGtnokT+eBRb0TfRUjIUeLO4IceIGhKn2zhYfftqgnEEgN6QcQwVqV8b4XK+r3fSYlTkHm6A= Received: by 10.70.53.7 with SMTP id b7mr942793wxa; Wed, 27 Sep 2006 09:11:16 -0700 (PDT) Received: by 10.70.130.3 with HTTP; Wed, 27 Sep 2006 09:11:15 -0700 (PDT) Message-ID: <58ed70f50609270911j79b22c66jb10df5dca5d84132@mail.gmail.com> Date: Wed, 27 Sep 2006 09:11:15 -0700 From: "Deepa Remesh" To: derby-dev@db.apache.org Subject: Re: autogenerated keys do not work with single column table In-Reply-To: <20060926033934.37351.qmail@web31302.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20060926033934.37351.qmail@web31302.mail.mud.yahoo.com> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N On 9/25/06, Bob Jaster wrote: > I have discovered that if I create a table with only one column, such as > > CREATE TABLE mo.company ( > id BIGINT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, > INCREMENT BY 1), > PRIMARY KEY (id) > ); > > then execute > > String sql = "INSERT INTO mo.company VALUES (DEFAULT)"; > PreparedStatement preparedStatement = connection.prepareStatement(sql, > Statement.RETURN_GENERATED_KEYS); > preparedStatement.executeUpdate(); > ResultSet resultSet = > preparedStatement.getGeneratedKeys(); > System.out.println("resultSet.next()==" + resultSet.next()); > Object object = resultSet.getObject(1); > if (object == null) { > System.out.println("object is null"); > } else { > long id = resultSet.getLong(1); > System.out.println("id==" + id); > } > > I always get null returned from resultSet.getObject(1), whereas if I add a > second column to the table (a VARCHAR(100)) then I get the generated key > value. > > Is this a bug? I tried your repro and I get the same problem with latest official release (10.1.3.1). However, when I tried with the latest 10.1 codeline and with 10.2 release candidate, I get correct results. So I think there was a bug which has been fixed in the latest codelines. It would be nice if you can try your application with the 10.2 release candidate and confirm this is not a problem. Details of 10.2 release candidate is available at http://wiki.apache.org/db-derby/TenTwoRelease Thanks, Deepa