It happens to the best :) Cheers, Lukas 2016-04-21 20:09 GMT+02:00 David Scott <[email protected]>:
> Wow - I feel foolish now. That was amazingly easy -- I was just trying to > make it too complicated. Thanks! > > > On Thursday, April 21, 2016 at 12:06:08 PM UTC-4, Lukas Eder wrote: >> >> Oh, overlooked the other one. That would be: >> >> Condition condition = DSL.trueCondition(); >> >> >> 2016-04-21 18:05 GMT+02:00 Lukas Eder <[email protected]>: >> >>> You already created the "standalone Condition object", you just hadn't >>> noticed :) >>> >>> Condition condition = CUSTOMERS.CUSTOMER_ID.in(specialList); >>> >>> >>> Hope this helps, >>> Lukas >>> >>> 2016-04-21 16:57 GMT+02:00 David Scott <[email protected]>: >>> >>>> Apologize if this is a dup -- original post appeared to have been eaten. >>>> >>>> I'm trying run two very similar queries with the only difference being >>>> in the join condition. I want to create single function to handle both >>>> queries, and just pass the correct join condition. Something like: >>>> >>>> public CustomerDTO noCondition(Integer id) { >>>> >>>> Condition condition = new TrueCondition(); >>>> return getCustomerParentById(id, condition); >>>> } >>>> >>>> public CustomerDTO special(Integer id, List<Integer> specialList) { >>>> >>>> Condition condition = new >>>> InCondition(CUSTOMERS.CUSTOMER_ID.in(specialList)); >>>> return getCustomerParentById(id, condition); >>>> } >>>> >>>> private List<CustomerDTO> getCustomerParentsById(Integer id, Condition >>>> condition) { >>>> >>>> List<CustomerDTO> customerDTOList = dslContext >>>> .select(CUSTOMERS.CUSTOMER_ID.as("id"), >>>> >>>> DSL.choose().when(PERSON.CUSTOMER_ID.notEqualIgnoreCase(""), >>>> PERSON.FIRST_NAME) >>>> .otherwise(INSTITUTIONS.NAME) >>>> .as("name"), >>>> CUSTOMERS.CUSTOMER_NUMBER.as("customerNumber"), >>>> CUSTOMER_TYPES.CUSTOMER_TYPE.as("customerType"), >>>> CUSTOMER_TYPES.CUSTOMER_TYPE_ID.as("customerTypeId")) >>>> .from(CUSTOMERS) >>>> >>>> .join(CUSTOMER_HIERARCHY).on(CUSTOMERS.CUSTOMER_ID.eq(CUSTOMER_HIERARCHY.PARENT_CUSTOMER_ID).and(condition)) >>>> >>>> .leftOuterJoin(CUSTOMER_TYPES).on(CUSTOMERS.CUSTOMER_TYPE_ID.eq(CUSTOMER_TYPES.CUSTOMER_TYPE_ID)) >>>> >>>> .leftOuterJoin(PERSON).on(PERSON.CUSTOMER_ID.equal(CUSTOMERS.CUSTOMER_ID)) >>>> >>>> .leftOuterJoin(INSTITUTIONS).on(INSTITUTIONS.CUSTOMER_ID.equal(CUSTOMERS.CUSTOMER_ID)) >>>> .where(CUSTOMER_HIERARCHY.CUSTOMER_ID.eq(id)) >>>> .fetchInto(CustomerDTO.class); >>>> >>>> >>>> return customerDTOList; >>>> >>>> } >>>> >>>> >>>> But I apparently can't create standalone Condition objects. Is there >>>> any way I can accomplish this (or something similar)? >>>> >>>> -- >>>> 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. >>>> >>> >>> >> -- > 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. > -- 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.
