One quick question though.
Is it possible to create an empty condition or something similar?

Dependent on field values I want to dynamically construct an condition.
The condition can be null (empty), 1 condition or 2 conditions.

Condition where = *some empty condition*;

if (StringUtils.isNotBlank(country)) {
    where = where.and(field("country.id").equal(country));
}
if (StringUtils.isNotBlank(name)) {
    where = where.and(field("driver.full_name").likeIgnoreCase(name));
}



The only thing I'm thinking of is to create the condition with something 
like 1=1.
Is that the best approach and can I create something like?

Condition where = field("1").equal(1);

(don't know if above syntax will work. Should I use field("1")?


Cheers,
Marcel

On Wednesday, February 3, 2016 at 4:12:12 PM UTC+1, Lukas Eder wrote:
>
> I'm glad to hear that! :)
>
> 2016-02-03 16:03 GMT+01:00 Marcel Overdijk <[email protected] 
> <javascript:>>:
>
>> OK thanks!
>>
>> I'm quite happy with the result of the experiment btw.
>>
>> Cheers,
>> Marcel
>>
>> On Wednesday, February 3, 2016 at 3:23:50 PM UTC+1, Lukas Eder wrote:
>>>
>>> Hi Marcel,
>>>
>>> 2016-02-03 12:50 GMT+01:00 Marcel Overdijk <[email protected]>:
>>>
>>> 1. I'm using the static table(..) and field(..) methods. Is this ok as 
>>>> it does not go through my DSLContext instance?
>>>
>>>  
>>> Sure. As a general rule of thumb: DSLContext.xxx() methods create DSL 
>>> objects in the context of a Configuration, which essentially contains 
>>> ConnectionProvider, Settings, SQLDialect, and other SPIs. This is useful 
>>> for creating executable statements, not for Field / Table / etc. 
>>> expressions.
>>>
>>> 2. Is there an easier way to construct the order by? Instead of creating 
>>>> a SortField<?>[] something like field(..).asc().and().field(..).asc() 
>>>> would 
>>>> be useful. Just like building the condition. Maybe this can be done 
>>>> already 
>>>> with current api?
>>>
>>>
>>> Hmm, no... But the artificial keyword appears a bit strange, no? In SQL, 
>>> a comma-separated list is used instead.
>>> Of course, you can supply a Collection<? extends SortField<?>> instead 
>>> of the array, if that better suits your needs... Most methods that accept 
>>> arrays/varargs also accept an equivalent collection argument.
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "jOOQ User Group" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] <javascript:>.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups "jOOQ 
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to