I think it can be improved but the javadocs indicates (executeUpdate) that the array is  ignored if the statement is not able to return an autogenerated key and the getGeneratedKeys says it will return an empty ResultSet if it cannot return generated keys.



Daniel John Debrunner wrote:
Lance J. Andersen wrote:

  
I discussed this briefly at my JDBC EG meeting yesterday.

As i expected, all of the vendors on the call indicated that they return
the same data type for key returned in the case of column defined as
identity via the getGeneratedKeys() method.  The consensus was that this
is what a user would expect.

As to the unique key question posed by Dan, this is going to be an
ongoing EG discussion as some vendors do return identity columns values
in cases that  are not unique (because the backend like Derby allows for
it) which gets complex as some vendors also in some cases support
returning a ROWID currently (but this is a difference scenario then
using a defined column in the table).
    

Beyond that it's also unclear what should a driver do if the application
requests columns in the ResultSet that are not generated or identity
columns.

E.g. with the example in section 13.6 of JDBC 4 what is the expected
behaviour if the column list is any of:

         {"ORDER_ID", "ISBN"}
         {"ISBN"}
         {"ORDER_DATE"}
         {"ORDER_ID", "ORDER_DATE"}

where ORDER_DATE is a column that has a default of CURRENT_DATE (ie.
value not provided by the INSERT).

Dan.





  

Reply via email to