How do I create a Field from a value T in jOOQ, explicitly?

16

In jOOQ, it is easy to use bind variables in expressions like:

MY_TABLE.COL.eq(1);
MY_TABLE.COL.in(1, 2, 3);
MY_TABLE.COL.between(1).and(10);

All of the above methods accept both T and Field<T> types, e.g. Field.eq(T) or Field.eq(Field<T>). But what if I want to put the bind variable on the left side of the expression? These obviously don't work:

1.eq(MY_TABLE.COL);
1.in(MY_TABLE.COL1, MY_TABLE.COL2, MY_TABLE.COL3);
1.between(MY_TABLE.COL1).and(MY_TABLE.COL2);

How can I turn those 1 or "xyz" into Field<Integer> or Field<String>, etc.?

(This is such a popular question on the jOOQ mailing list, etc., so I'm documenting it here)

Share
Improve this question
0

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

React Native - Image Cache