Re: [DbUtils] Returning the newly-generated primary key after an insert

2012-02-01 Thread Moandji Ezana
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

2012-01-31 Thread Moandji Ezana
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


[DbUtils] Returning the newly-generated primary key after an insert

2012-01-29 Thread Moandji Ezana
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

2012-01-29 Thread Moandji Ezana
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

2012-01-29 Thread Moandji Ezana
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
 



Re: [dbutils] Mapping from JPA annotations

2012-01-19 Thread Moandji Ezana
Interesting. I've never used MyBatis, but U've read the docs and it didn't
really seem to help write less SQL.

Do you all only use DbUtils for smaller projects, then?

Moandji
On 19 Jan 2012 22:32, Simone Tripodi simonetrip...@apache.org wrote:

 I personally use MyBatis[1] - which is DbUtils with superpowers

 -Simo

 [1] http://www.mybatis.org

 http://people.apache.org/~simonetripodi/
 http://simonetripodi.livejournal.com/
 http://twitter.com/simonetripodi
 http://www.99soft.org/



 On Thu, Jan 19, 2012 at 9:28 PM, Moandji Ezana mwa...@gmail.com wrote:
  On 19 Jan 2012 20:26, Gary Gregory garydgreg...@gmail.com wrote:
 
  So why not use Hibernate or any JPA provider?
 
  Gary
 
  Plenty of reasons, such as the library's simplicity and the control it
  affords. And I don't want the lazy-loading, 1st-level cache, etc. it
  provides.
 
  However, there are 2 big missing pieces: reducing the amount of
 duplication
  in SQL (which makes refactoring the code or the DB difficult) and mapping
  joins.
 
  Arguably, SQL generation is out of scope. Joins, however, shouldn't be. I
  think JPA annotations
 
  Out of curiosity, how do you guys manage the SQL strings and the joins in
  your projects?
 
  Moandji

 -
 To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
 For additional commands, e-mail: user-h...@commons.apache.org