Class BitwiseUtils
java.lang.Object
ubic.gemma.persistence.util.BitwiseUtils
Helpers for emitting portable native-SQL bitwise operations.
MySQL uses the a & b operator; H2 (in MODE=MYSQL or otherwise) needs the
BITAND(a, b) function — & either doesn't parse or behaves as concatenation in
some modes. Gemma is MySQL-only in production via MySQL57Dialect, but tests use H2 with
MODE=MYSQL, so native-SQL ACL queries that mask on permission bits need to render
differently per dialect.
Phase 2 background: pre-Phase-2 this routed through Dialect.getSqlFunctionRegistry(),
which changed shape in Hibernate 6. Phase 2 Step 3 inlined (a & b) as MySQL-only; this
util restores dialect-awareness without going back through Hibernate's function registry.
- Author:
- poirigui (Phase 2)
-
Method Summary
-
Method Details
-
bitand
Emit a native-SQL bitwise-AND expression appropriate for the given HibernateDialect.- Parameters:
dialect- the runtime database dialect (e.g.MySQL57InnoDBDialect,H2Dialect)left- left-hand SQL expression (column reference, parameter, etc.)right- right-hand SQL expression- Returns:
- SQL fragment, e.g.
(a & 1)on MySQL orBITAND(a, 1)on H2
-