How does bitwise_and work in Postgres 9.4 and Hibernate 5
<p>We are using PostgreSQl 9.4, and Hibernate 5.1 which seems to be somewhat the latest versions.  I know Postgres 9.5 is out, but 9.4 doesn't seem so old.
We use JPA with Hibernate 5.1 and create HQL Queries.</p>

<p>We have a field in the database which is a bigint.  This is a bitmask for us, stored as an integer.  In the java code, this works great, but when we want to check for bitmasks, it doesn't work.  </p>

<pre><code>ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - 
ERROR: function bitwise_and(bigint, integer) does not exist
Hint: No function matches the given name and argument types. 
You might need to add explicit type casts.
</code></pre>

<p>I'm looking at the generated hibernate sql and I can see that we have something like:</p>

<pre><code>bitwise_and(mytable_.actionbitmask, 2)&gt;0 
</code></pre>

<p>So, I'd like to get the raw SQL to work first, and then I can tweak my HQL query to make that work also.</p>

<p>Now, I have searched Google, and all the results come back with:
 - can't be done in HQL, have to use regular sql
But most of these are very old comments, and since Postgres is 9.4, Hibernate is 5.1, I'm thinking surely by now we can figure this out with some examples.</p>

<p>Unfortunately, even the Postgres 9.4 bit operations don't even show bitwise_and at all, the documentation just sucks there.  </p>

<p>Should I convert my decimals/longs to binaries of the same length in the sql string before I execute the HQL?</p>

<p>Any help would be much appreciated.  Thanks!</p>