You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Moandji Ezana (Created) (JIRA)" <ji...@apache.org> on 2012/02/01 07:54:58 UTC

[jira] [Created] (DBUTILS-87) Return generated key on insert

Return generated key on insert
------------------------------

                 Key: DBUTILS-87
                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
             Project: Commons DbUtils
          Issue Type: New Feature
            Reporter: Moandji Ezana


It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Resolved] (DBUTILS-87) Return generated key on insert

Posted by "William R. Speirs (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William R. Speirs resolved DBUTILS-87.
--------------------------------------

       Resolution: Implemented
    Fix Version/s: 1.6

Code submitted, r1370883
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>             Fix For: 1.6
>
>         Attachments: AsyncQueryRunner_add_insert_methods.patch, QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DBUTILS-87) Return generated key on insert

Posted by "Sebb (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13197710#comment-13197710 ] 

Sebb commented on DBUTILS-87:
-----------------------------

Javadoc needs to be added for the new public methods.
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DBUTILS-87) Return generated key on insert

Posted by "Moandji Ezana (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Moandji Ezana updated DBUTILS-87:
---------------------------------

    Attachment: AsyncQueryRunner_add_insert_methods.patch

AsyncQueryRunner_add_insert_methods.patch adds insert methods to AsyncQueryRunner and unit tests verify that call is delegated to the wrapped QueryRunner.
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>         Attachments: AsyncQueryRunner_add_insert_methods.patch, QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Updated] (DBUTILS-87) Return generated key on insert

Posted by "Moandji Ezana (Updated) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Moandji Ezana updated DBUTILS-87:
---------------------------------

    Attachment: QueryRunner_insert.txt

Here is a patch that adds the insert methods and a very basic unit test, just to get the ball rolling.
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DBUTILS-87) Return generated key on insert

Posted by "Moandji Ezana (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13197766#comment-13197766 ] 

Moandji Ezana commented on DBUTILS-87:
--------------------------------------

@Sebb: I agree, but I wanted to get some initial feedback on whether the functionality is desired, implemented in a sane way, etc.

As soon as that is agreed, I'll fill in the documentation, fix any code style mistakes and also add this functionality to the AsyncQueryRunner and (if possible) batch methods.
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DBUTILS-87) Return generated key on insert

Posted by "Moandji Ezana (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13202804#comment-13202804 ] 

Moandji Ezana commented on DBUTILS-87:
--------------------------------------

"Looking at this patch I noticed that there are two other possible calls which users might want to create the prepared statement:

prepareStatement(String sql, int[] columnIndexes)
prepareStatement(String sql, String[] columnNames)"

What would you see as the API for this? While I agree that those could be useful, I'm not sure it's really necessary:

1. Multi-column primary keys might be handled by the JDBC driver, if all columns are defined as being part of the primary key. This is pure speculation on my part.

2. Multi-column primary keys are fairly rare.

3. Whatever the API we come up with has to be replicated in the AsyncQueryRunner, so it's a lot of extra methods.

"Otherwise, the patch is missing (as noted above) JavaDocs and the async implementation, but looks sound. If you can update your patch with these additional things, I'll look to commit it. Thanks!"

Cool. I'll try to make time for it this week.
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DBUTILS-87) Return generated key on insert

Posted by "Moandji Ezana (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13211358#comment-13211358 ] 

Moandji Ezana commented on DBUTILS-87:
--------------------------------------

I'm waiting for DBUTILS-88 to be resolved before adding the insert methods to AsyncQueryRunner.
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Issue Comment Edited] (DBUTILS-87) Return generated key on insert

Posted by "Moandji Ezana (Issue Comment Edited) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13197624#comment-13197624 ] 

Moandji Ezana edited comment on DBUTILS-87 at 2/1/12 6:56 AM:
--------------------------------------------------------------

QueryRunner_insert.txt is a patch that adds the insert methods and a very basic unit test, just to get the ball rolling.
                
      was (Author: mwanji):
    Here is a patch that adds the insert methods and a very basic unit test, just to get the ball rolling.
                  
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DBUTILS-87) Return generated key on insert

Posted by "William R. Speirs (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13200795#comment-13200795 ] 

William R. Speirs commented on DBUTILS-87:
------------------------------------------

Looking at this patch I noticed that there are two other possible calls which users might want to create the prepared statement:

prepareStatement(String sql, int[] columnIndexes)
prepareStatement(String sql, String[] columnNames)

This would be in the case that the insert call auto-generates more than one column of keys (a good example of doing that is escaping me now, but ...). With the call in the current patch prepareStatement(String sql, int autoGeneratedKeys) JDBC will, "determine the columns which best represent the auto-generated keys." [1]

I don't have much experience with this, but do we think this would bite people? It's always hard to tell when it's JDBC driver implementation specific. Thoughts?

Otherwise, the patch is missing (as noted above) JavaDocs and the async implementation, but looks sound. If you can update your patch with these additional things, I'll look to commit it. Thanks!

[1] http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html#getGeneratedKeys()
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (DBUTILS-87) Return generated key on insert

Posted by "William R. Speirs (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DBUTILS-87?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13203744#comment-13203744 ] 

William R. Speirs commented on DBUTILS-87:
------------------------------------------

Yea, I don't have any good ideas for this API. Lets stick with what you have for now, see how that looks and what folks think of it, then we can add additional methods later. Thanks!
                
> Return generated key on insert
> ------------------------------
>
>                 Key: DBUTILS-87
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-87
>             Project: Commons DbUtils
>          Issue Type: New Feature
>            Reporter: Moandji Ezana
>            Assignee: William R. Speirs
>         Attachments: QueryRunner_insert.txt
>
>
> It would be useful to have an insert method on QueryRunner that returns the id of the new record.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira