db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lance J. Andersen" <Lance.Ander...@Sun.COM>
Subject Re: behavior of Statement.getGeneratedKeys()
Date Mon, 10 Jul 2006 18:50:33 GMT
To me this is a problematic issue as i would expect the return type for 
the keys to match the datatype of the column.

Rick Hillegas wrote:
> 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 
> 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
> **

View raw message