db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <Richard.Hille...@Sun.COM>
Subject behavior of Statement.getGeneratedKeys()
Date Mon, 10 Jul 2006 17:51:19 GMT
I would like the community's advice on whether the following Derby 
behavior is a bug and, if so, whether we would be allowed to change this 
behavior for 10.2:

A) Currently, Derby knows how to automatically generate values for 
columns of type SMALLINT, INT, and BIGINT. You get this behavior if you 
declare the column with this clause: "generated {always | by default} as 
identity".

B) You can retrieve autogenerated values using the 
Statement.getGeneratedKeys() call. This call returns a ResultSet with a 
DECIMAL column. That is, the autogenerated keys come back as DECIMAL 
even though they actually appear in the table as SMALLINT, INT, or BIGINT.

This seems a bit odd. One might expect that the returned keys would have 
the same datatype as the actual autogenerated value in the table. 
However, technically the javadoc for Statement.getGeneratedKeys() 
doesn't specify the shape of the ResultSet and we don't lose any 
precision. You can retrieve the value in the database by calling the 
appropriate getXXX() method on the DECIMAL result returned by 
Statement.getGeneratedKeys().

Before filing a bug on this, I'd like the community's advice:

1) Is this a bug? Should Statement.getGeneratedKeys() return a ResultSet 
whose column has the same type as the underyling autogenerated column?

2) If this is a bug, is it permitted to change this behavior in a minor 
release?

Thanks,
-Rick
**

Mime
View raw message