You can find some information about bitwise operators / bitwise functions in the relevant section of the jOOQ manual.
Concretely, using DSL.bitAnd()
:
DSL.bitAnd(TABLE_A.PRODUCTS, 255);
See also the related discussion on the jOOQ User Group.
题
We're just switching to using JOOQ in place of standard DAO and straight SQL and I'm trying to convert this SQL to JOOQ context:
products is defined as INT(4) field in MySQL 5.6.
SELECT DISTINCT f1
FROM table_A WHERE
(f1 IS NOT NULL)
AND (products & 255)
AND (age <= 180)
AND (flag < 1)
ORDER BY f1;
JOOQ version:
context.selectDistinct(TABLE_A.F1).from(TABLE_A).where(TABLE_A.F1.isNotNull())
.and(TABLE_A.flag.lessthan(UInteger.valueof(1))
.and(TABLE_A.age.lessthan(UInteger.valueof(180))
.orderBy(TABLE_A.f1);
What I can't seem to figure out is how to do the (products & 255) bitwise operation.
解决方案
You can find some information about bitwise operators / bitwise functions in the relevant section of the jOOQ manual.
Concretely, using DSL.bitAnd()
:
DSL.bitAnd(TABLE_A.PRODUCTS, 255);
See also the related discussion on the jOOQ User Group.