In spring boot using JPQL how to use bitwise operator.
select * from myTable where col1&3600 = 2222
I also see this old post
JPA @NamedQuery with bitwise AND (&) as criteria
gives a way for using MOD but it gives only way to check 1 bit.
Here col1 has integer value. Example :
Col1
-----
1111111
1010010
1101110
My query is dynamic like I want to know (1,4,6) or (1,2,4,7) or any set of position bit is on or not. That's why I am thinking from set of position I will build a integer where position bit's are on like.
(1,4,6) - 0101001
(1,2,4,7)- 1001011
and do bitwise operation with col1 lik col1 & myBitmask > 0
then
I can fetch data where have atleast one position from the searching position set have bit 1.
1111111 & 0101001 = 0101001
1010010 & 0101001 = 0000000
1101110 & 0101001 = 0101000
So I will get 1st and 3rd data only.
Now their is any better way ?