How to use bitwise operators in QueryDSL?

46 views
Skip to first unread message

Ali Hammoud

unread,
Feb 28, 2017, 12:23:14 PM2/28/17
to Querydsl
Hi,

In my project, i have a bit field (int) named flag, and i need to query the database using several criteria, one of them is the flag field, so what i need is to send a bitwise_AND.

I tried using QuerydslBinderCustomizer but couldn't find any method which apply any bitwise operator.
I also tried to create a custom BooleanExpression to return it to the bindings.bind which apply the bitwise operator manually, but also it didn't work.

This is an example of what I need:

public interface RateRepository extends CrudRepository<Rate,RatePK>, QueryDslPredicateExecutor<Rate>, QuerydslBinderCustomizer<QRate> {

    @Override
    default void customize(QuerydslBindings bindings, QRate qRate) {
bindings.bind(qRate.rateId).first(
(path, value) -> {
return (path & value > 0) //Something like this, or a function like:
                    //return (bitwise_AND(path, value) > 0);
});
}
}

How could this be done?

Thank you.
Reply all
Reply to author
Forward
0 new messages