On second thought...

If you're intention is to *filter* a list of results by name, age, id, etc
(rather than to look up individual records), then you'll probably want to
perform the filtration in the database. The alternative (retrieving all
records in the DB and then filtering in application code) could impose an
undesirable amount of transferred data.

In which case your question is really about SQL rather than Dropwizard or
jDBI.

On Sat, Oct 15, 2016 at 2:39 PM, Evan Meagher <evan.meag...@gmail.com>
wrote:

> Hello Kim,
>
> Based on my understanding of your situation, I would advise the approach
> of using the simplest possible DAO methods and keeping the query complexity
> within your application code. For instance, if a GET endpoint takes name,
> age, id, etc as query parameters, your resource method could fire off
> simple `SELECT * FROM table_name WHERE foo = bar` depending on whatever
> condition(s) you want.
>
> This is simply because I find application code to be easier to test and
> maintain, in contrast to SQL code inlined as strings in annotations.
>
> On Fri, Oct 14, 2016 at 1:15 PM, Kim Kantola <kkant...@gmail.com> wrote:
>
>> Hi All,
>>
>> I am new to JDBI.  I have seen several simple examples of annotating a
>> DAO with a query like "Select * from tableName where id=?".
>>
>> Could someone point me to documentation for more complex queries such as
>> searching by a dynamic list of parameters?  For example, a user can search
>> by name, age, id, height, etc, but I am unaware until runtime which
>> combination of these search parameters may come in to my search method.  I
>> may not get a search value for age, and so do not need to bind anything to
>> the search query for that.
>>
>> Any pointers appreciated,
>> ~Kim
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "dropwizard-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to dropwizard-user+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Evan Meagher
>



-- 
Evan Meagher

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dropwizard-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to