Re: How to implement order by field value with jOOQ's dynamic queries

2015-02-16 Thread Lukas Eder
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 FieldInteger field(FieldString search, String in1) {
return field(search, DSL.val(in1));
}

public static FieldInteger field(FieldString search,
FieldString in1) {
return DSL.field(field({0}, {1}), Integer.class, search, in1);
}

public static FieldInteger field(FieldString search,
   String in1,
   String in2) {
return field(search, val(in1), val(in2));
}

public static FieldInteger field(FieldString search,
   FieldString in1,
   FieldString 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 eelco.hillen...@gmail.com:

 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 jooq-user+unsubscr...@googlegroups.com.
 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 jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to implement order by field value with jOOQ's dynamic queries

2015-02-16 Thread Eelco Hillenius
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 FieldInteger field(FieldString search, String in1) {
 return field(search, DSL.val(in1));
 }

 public static FieldInteger field(FieldString search, FieldString 
 in1) {
 return DSL.field(field({0}, {1}), Integer.class, search, in1);
 }

 public static FieldInteger field(FieldString search, 
String in1, 
String in2) {
 return field(search, val(in1), val(in2));
 }

 public static FieldInteger field(FieldString search, 
FieldString in1, 
FieldString 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 eelco.h...@gmail.com 
 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 jooq-user+...@googlegroups.com 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 jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to implement order by field value with jOOQ's dynamic queries

2015-02-16 Thread Lukas Eder
You can post wherever you prefer. If you post to both places, it's always a
good idea to cross-link between them (as you did).

2015-02-16 15:49 GMT+01:00 Eelco Hillenius eelco.hillen...@gmail.com:

 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 FieldInteger field(FieldString search, String in1) {
 return field(search, DSL.val(in1));
 }

 public static FieldInteger field(FieldString search, FieldString 
 in1) {
 return DSL.field(field({0}, {1}), Integer.class, search, in1);
 }

 public static FieldInteger field(FieldString search,
String in1,
String in2) {
 return field(search, val(in1), val(in2));
 }

 public static FieldInteger field(FieldString search,
FieldString in1,
FieldString 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 eelco.h...@gmail.com:

 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 jooq-user+...@googlegroups.com.
 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 jooq-user+unsubscr...@googlegroups.com.
 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 jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to implement order by field value with jOOQ's dynamic queries

2015-02-14 Thread Eelco Hillenius
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 jooq-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.