score:2

Accepted answer

You could extend the Oracle dialect and add BITAND as a recoginzed HQL function:

public class OraclePlusDialect : Oracle10gDialect
{
    public OraclePlusDialect()
    {
        RegisterFunction("bitand", new StandardSQLFunction("bitand", NHibernateUtil.Int32));
    }    
}

Then you should be able to execute your query like this:

var objects =  _session.CreateQuery("select c from MyClass c 
                     where bitand(c.someInteger, :param) > 0")
                 .SetParameter("param", otherInteger)
                 .List<MyClass>();

Possibly, Oracle has a type conversion problem becuase BITAND returns a rarely used data type. If this is the case, modify your HQL query to:

select c from MyClass c 
    where bitand(c.someInteger, :param) + 0 > 0

Related Articles