db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jean T. Anderson" <...@bristowhill.com>
Subject Should getGeneratedKeys() return a NULL key after commit/rollback?
Date Thu, 15 Mar 2007 23:34:07 GMT
I'm converting the autoGeneratedJdbc30.java test to Junit (DERBY-2398)
and the original writer of that test embedded comments questioning some
behavior, which I thought I'd raise here.

I included links down below for the original code [1] and one of the [2]
masters.

Test 11 in the original does this sequence involving a commit:

1) inserts a row into a table that has an auto-generated column
2) does a commit
3) inserts into a table that does not have an auto-generated column, and
specifies RETURN_GENERATED_KEYS
4) getGeneratedKeys() returns a non-NULL key. The code outputs this comment:
System.out.println("expected to see resultset with one row of NULL value
but instead get one row of non-NULL value from getGeneratedKeys");

Test 12 in the original does the same sequence, but with a rollback, and
it has the same non-NULL result (and same comment about "expected to see
resultset with one row of NULL value ....").

Is this behavior correct?

Is there a resource I can consult to verify correct behavior? --I
checked the API specs for getGeneratedKeys [3] and didn't find details.

thanks,

-jean


[1] This link to the source code will be good even after the file is svn
deleted (i.e., links in this email will remain good):
http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/autoGeneratedJdbc30.java?revision=515102&view=markup

[2] This link to the master will be good even after the file is svn deleted:
http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/autoGeneratedJdbc30.out?revision=429425&view=markup

[3]
http://java.sun.com/j2se/1.4.2/docs/api/java/sql/Statement.html#getGeneratedKeys()

Mime
View raw message