[jira] [Created] (DBUTILS-99) Create QueryRunner Factory

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] [Created] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
William R. Speirs created DBUTILS-99:
----------------------------------------

             Summary: Create QueryRunner Factory
                 Key: DBUTILS-99
                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
             Project: Commons DbUtils
          Issue Type: Improvement
    Affects Versions: 1.5
            Reporter: William R. Speirs
            Assignee: William R. Speirs
            Priority: Minor


Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437871#comment-13437871 ]

Simone Tripodi commented on DBUTILS-99:
---------------------------------------

What do you mean for _there is no good way to use dependency injection with QueryRunners_?

I can obtain {{QueryRunner}} instances using _Google Guice_ (a dependency injection framework) in a very clean way (via {{Provider}} and {{Binder}}), but maybe I am missing some details. What do you intend to add?

I am asking just because I am curious, nothing strictly related to DBUTILS! :)
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437904#comment-13437904 ]

Moandji Ezana commented on DBUTILS-99:
--------------------------------------

I'm also curious what you mean. Like Simone, I've found it easy to use QueryRunners with Guice.
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437922#comment-13437922 ]

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

Maybe this is my mis-understanding of dependency injection. I don't use Guice and simply inject my dependencies via the constructor, so something like:

{code:borderStyle=solid}
public MyClass(QueryRunnerFactory factory) {
  this.factory = factory;
}
{code}

This way I can simply mock up an instance of QueryRunnerFactory in my unit tests and provide fake results from the DB. Maybe this isn't useful for others?
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437924#comment-13437924 ]

Simone Tripodi commented on DBUTILS-99:
---------------------------------------

Got it, thanks - and apologize, _dependency injection_ made me think indeed thinking about a DI Framework (Spring, Guice) and that's why I didn't understand why you wrote _ there is no good way to use dependency injection with QueryRunners_

I wouldn't have had objections on adding the {{QueryRunnerFactory}} in any case, mine was just a matter of curiosity :)
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Comment Edited] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437924#comment-13437924 ]

Simone Tripodi edited comment on DBUTILS-99 at 8/21/12 2:12 AM:
----------------------------------------------------------------

Got it, thanks - and apologize, _dependency injection_ made me think indeed thinking about a DI Framework (Spring, Guice) and that's why I didn't understand why you wrote _there is no good way to use dependency injection with QueryRunners_

I wouldn't have had objections on adding the {{QueryRunnerFactory}} in any case, mine was just a matter of curiosity :)
               
      was (Author: simone.tripodi):
    Got it, thanks - and apologize, _dependency injection_ made me think indeed thinking about a DI Framework (Spring, Guice) and that's why I didn't understand why you wrote _ there is no good way to use dependency injection with QueryRunners_

I wouldn't have had objections on adding the {{QueryRunnerFactory}} in any case, mine was just a matter of curiosity :)
                 

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13437966#comment-13437966 ]

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

I guess this should have hit the mailing list before JIRA, but what do people think... worth adding the class? Or, not something we want to bloat the library with because as both Simone and Moandji pointed out, frameworks like Spring and Guice can do this for people.
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13438268#comment-13438268 ]

Moandji Ezana commented on DBUTILS-99:
--------------------------------------

I use constructor injection with Guice as well. Why can't you just do:

public MyClass(QueryRunner queryRunner)

Unit tests could still inject whatever instance they like.

Maybe I'm missing your point. What would the factory's API be?
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Commented] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

    [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13438366#comment-13438366 ]

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

I'm slightly embarrassed to say that even though I was the one who created the AbstractQueryRunner, I had forgotten that was reusable and thread safe. For some reason I had the impression that reusing a QueryRunner was a bad idea.

Time to go remove some code at work :-)
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>             Fix For: 1.5
>
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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

       
Reply | Threaded
Open this post in threaded view
|

[jira] [Resolved] (DBUTILS-99) Create QueryRunner Factory

AD_LB (Jira)
In reply to this post by AD_LB (Jira)

     [ https://issues.apache.org/jira/browse/DBUTILS-99?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

William R. Speirs resolved DBUTILS-99.
--------------------------------------

       Resolution: Not A Problem
    Fix Version/s: 1.5

A factory class is not needed for QueryRunner as they can be safely reused and are thread safe.
               

> Create QueryRunner Factory
> --------------------------
>
>                 Key: DBUTILS-99
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-99
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: William R. Speirs
>            Assignee: William R. Speirs
>            Priority: Minor
>             Fix For: 1.5
>
>
> Currently there is no good way to use dependency injection with QueryRunners. Creating a simple factory class to allow for easy injection (and therefore easier unit test creation) should solve this problem.

--
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