Re: [DbUtils] Returning the newly-generated primary key after an insert
Hi Simone, On Wed, Feb 1, 2012 at 9:24 AM, Simone Tripodi simonetrip...@apache.orgwrote: I had a quick look at the patch and IMHO it looks good. I assigned the issue to Bill who's more deep inside DbUtils than me :) All the best and thanks for contributing! Thanks! I should be able to make some time to make any necessary changes, like adding JavaDoc, a few more unit tests, etc. Moandji
Re: [DbUtils] Returning the newly-generated primary key after an insert
Thanks! I should be able to make some time to make any necessary changes, like adding JavaDoc, a few more unit tests, etc. Moandji thanks, that would be really appreciated! best, -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [DbUtils] Returning the newly-generated primary key after an insert
I'll take a look when I can, but more unit tests and docs are always welcome :-) Thanks... Bill- On Feb 1, 2012 3:43 AM, Simone Tripodi simonetrip...@apache.org wrote: Thanks! I should be able to make some time to make any necessary changes, like adding JavaDoc, a few more unit tests, etc. Moandji thanks, that would be really appreciated! best, -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [DbUtils] Returning the newly-generated primary key after an insert
On Sun, Jan 29, 2012 at 6:21 PM, William Speirs wspe...@apache.org wrote: Interesting... would you be willing to donate your QueryRunner implementation? If so, open a JIRA ticket[1] with your request for this functionality, and upload your code. Done, with embryonic patch: https://issues.apache.org/jira/browse/DBUTILS-87 Moandji
Re: [DbUtils] Returning the newly-generated primary key after an insert
Hi Moandji, I had a quick look at the patch and IMHO it looks good. I assigned the issue to Bill who's more deep inside DbUtils than me :) All the best and thanks for contributing! -Simo http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Wed, Feb 1, 2012 at 7:58 AM, Moandji Ezana mwa...@gmail.com wrote: On Sun, Jan 29, 2012 at 6:21 PM, William Speirs wspe...@apache.org wrote: Interesting... would you be willing to donate your QueryRunner implementation? If so, open a JIRA ticket[1] with your request for this functionality, and upload your code. Done, with embryonic patch: https://issues.apache.org/jira/browse/DBUTILS-87 Moandji - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
[DbUtils] Returning the newly-generated primary key after an insert
Is it possible with the current API to do an insert and get back the generated primary key, rather than the number of affected rows? Best regards, Moandji
Re: [DbUtils] Returning the newly-generated primary key after an insert
That is a question more specific to the database you're using, than DBUtils. For some databases this means writing a stored procedure which performs the insert, and then a special select to get the primary key. You can of course use DBUtils to call this stored proc and read the primary key. Hope this helps... Bill- On Sun, Jan 29, 2012 at 9:44 AM, Moandji Ezana mwa...@gmail.com wrote: Is it possible with the current API to do an insert and get back the generated primary key, rather than the number of affected rows? Best regards, Moandji
Re: [DbUtils] Returning the newly-generated primary key after an insert
Hi Bill, we could manage at least the generated keys, using Statement#getGeneratedKeys()[1], requiring a non null ResultSetHandler. To not break APIs backward compatibility, that could be a new set of APIs... WDYT? best, -Simo [1] http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#getGeneratedKeys() http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ On Sun, Jan 29, 2012 at 5:05 PM, William Speirs wspe...@apache.org wrote: That is a question more specific to the database you're using, than DBUtils. For some databases this means writing a stored procedure which performs the insert, and then a special select to get the primary key. You can of course use DBUtils to call this stored proc and read the primary key. Hope this helps... Bill- On Sun, Jan 29, 2012 at 9:44 AM, Moandji Ezana mwa...@gmail.com wrote: Is it possible with the current API to do an insert and get back the generated primary key, rather than the number of affected rows? Best regards, Moandji - To unsubscribe, e-mail: user-unsubscr...@commons.apache.org For additional commands, e-mail: user-h...@commons.apache.org
Re: [DbUtils] Returning the newly-generated primary key after an insert
On Sun, Jan 29, 2012 at 6:05 PM, William Speirs wspe...@apache.org wrote: That is a question more specific to the database you're using, than DBUtils. For some databases this means writing a stored procedure which performs the insert, and then a special select to get the primary key. You can of course use DBUtils to call this stored proc and read the primary key. As Simone mentioned, I'd like to use Statement#getGeneratedKeys(), which requires passing Statement.RETURN_GENERATED_KEYS to Connection#prepareStatement(). It doesn't seem possible to do this with the current API. I've written my own QueryRunner for the time being, but it seems like a common enough requirement to be in the library itself. Moandji
Re: [DbUtils] Returning the newly-generated primary key after an insert
Interesting... would you be willing to donate your QueryRunner implementation? If so, open a JIRA ticket[1] with your request for this functionality, and upload your code. Thanks... Bill- [1] https://issues.apache.org/jira/browse/DBUTILS On Sun, Jan 29, 2012 at 11:19 AM, Moandji Ezana mwa...@gmail.com wrote: On Sun, Jan 29, 2012 at 6:05 PM, William Speirs wspe...@apache.org wrote: That is a question more specific to the database you're using, than DBUtils. For some databases this means writing a stored procedure which performs the insert, and then a special select to get the primary key. You can of course use DBUtils to call this stored proc and read the primary key. As Simone mentioned, I'd like to use Statement#getGeneratedKeys(), which requires passing Statement.RETURN_GENERATED_KEYS to Connection#prepareStatement(). It doesn't seem possible to do this with the current API. I've written my own QueryRunner for the time being, but it seems like a common enough requirement to be in the library itself. Moandji
Re: [DbUtils] Returning the newly-generated primary key after an insert
I don't mind, but it's a very limited implementation. I don't know if it's abywhere near general-purpose for your needs. I'll post it and let you decide. Moandji On 29 Jan 2012 18:21, William Speirs wspe...@apache.org wrote: Interesting... would you be willing to donate your QueryRunner implementation? If so, open a JIRA ticket[1] with your request for this functionality, and upload your code. Thanks... Bill- [1] https://issues.apache.org/jira/browse/DBUTILS On Sun, Jan 29, 2012 at 11:19 AM, Moandji Ezana mwa...@gmail.com wrote: On Sun, Jan 29, 2012 at 6:05 PM, William Speirs wspe...@apache.org wrote: That is a question more specific to the database you're using, than DBUtils. For some databases this means writing a stored procedure which performs the insert, and then a special select to get the primary key. You can of course use DBUtils to call this stored proc and read the primary key. As Simone mentioned, I'd like to use Statement#getGeneratedKeys(), which requires passing Statement.RETURN_GENERATED_KEYS to Connection#prepareStatement(). It doesn't seem possible to do this with the current API. I've written my own QueryRunner for the time being, but it seems like a common enough requirement to be in the library itself. Moandji