Thanks Lucas, that's a nicer answer. For future reference, do you prefer questions to this list or on StackOverflow?
Cheers, Eelco On Monday, February 16, 2015 at 9:44:01 AM UTC-5, Lukas Eder wrote: > > Hi there. > > I see that your own answer has crossed mine here: > http://stackoverflow.com/a/28543891/521799 > > For the record, I'm still going to post my Stack Overflow answer again > here on the jOOQ user group: > > Whenever you hit jOOQ's limits, resort to plain SQL > <http://www.jooq.org/doc/latest/manual/sql-building/plain-sql/>. You can > write your own field function like this: > > class MyDSL { > > public static Field<Integer> field(Field<String> search, String in1) { > return field(search, DSL.val(in1)); > } > > public static Field<Integer> field(Field<String> search, Field<String> > in1) { > return DSL.field("field({0}, {1})", Integer.class, search, in1); > } > > public static Field<Integer> field(Field<String> search, > String in1, > String in2) { > return field(search, val(in1), val(in2)); > } > > public static Field<Integer> field(Field<String> search, > Field<String> in1, > Field<String> in2) { > return DSL.field("field({0}, {1}, {2})", Integer.class, search, in1, > in2); > } > > // ... or, support a varargs function variant, too} > > And now use that in all your statements: > > query.addOrderBy( MyDSL.field(BAR.FOO, "value1", "something-else", "value3") > ); > > > 2015-02-14 15:50 GMT+01:00 Eelco Hillenius <[email protected] > <javascript:>>: > >> Hi, >> >> >> I'm trying to get this : >> >> select foo from bar order by field(foo, 'value1', 'something-else', >> 'value3') >> >> into a select query, but can't figure out how to translate the 'field' >> function in the context of order by. Any idea how to do this? >> >> Eelco >> >> btw, I also posted this question to Stackoverflow ( >> http://stackoverflow.com/questions/28508176/how-to-implement-order-by-field-value-with-jooqs-dynamic-queries). >> >> What is in general the preferred way of asking questions for jOOQ? >> >> -- >> 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.
