Search code examples
sqlhibernatehql

What is "bw_and" in hibernate query


I found a strange query implemented in my project, when I debug and inspect the persistance.query Object just before it call getResultList() method, the queryString I found is :

FROM AbcTbl a WHERE bw_and(a.column1, :column1) <> 0

This query is working fine and fetching all data from AbcTbl table where a.column1= :column1.

I am not able to understand yet what is bw_and in this query syntax. Could anyone have any idea?

I am using sqlServer2014 and direct query with bw_and is not acceptable by sqlServer.


Solution

  • In My application below class is used which register bw_and as bitwise operator

    public class ExtendedMSSQLServerDialect extends SQLServerDialect {
    
        public ExtendedMSSQLServerDialect() {
            super();
            registerFunction("bw_and", new BitwiseSQLFunction(BitwiseSQLOperator.AND, "bw_and"));
            registerFunction("bw_or", new BitwiseSQLFunction(BitwiseSQLOperator.OR, "bw_or"));
            registerFunction("cast_text_to_varchar_of_length", new CastTextToVarcharSQLFunction("cast_text_to_varchar_of_length"));
        }
    }