[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-160) New query parser does not allow bitwise operations

Chris Wood (JIRA) noreply at atlassian.com
Wed Oct 4 22:26:24 EDT 2006


    [ http://opensource.atlassian.com/projects/hibernate/browse/HHH-160?page=comments#action_24724 ] 

Chris Wood commented on HHH-160:
--------------------------------

BTW: the registerFunction line for bit_and and bit_or can take advantage of org.hibernate.dialect.function.VarArgsSQLFunction.

Using this you can get rid of the inner class, and just do the following in the constructor:

    registerFunction("bit_not", new SQLFunctionTemplate(Hibernate.INTEGER, "~?1"));
    registerFunction("bit_and", new VarArgsSQLFunction(Hibernate.INTEGER, "(", "&", ")"));
    registerFunction("bit_or", new VarArgsSQLFunction(Hibernate.INTEGER, "(", "|", ")"));

Note the additional surrounding brackets, this ensures the function-like behaviour rather than using the DB's operator precidence.

> New query parser does not allow bitwise operations
> --------------------------------------------------
>
>          Key: HHH-160
>          URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-160
>      Project: Hibernate3
>         Type: Improvement

>   Components: core
>     Versions: 3.0 rc 1
>  Environment: Hibernate 3.0 rc1, MySQL
>     Reporter: Markus Jessenitschnig
>     Priority: Minor

>
>
> The new query parser does not allow bitwise operations like bitwise-and and bitwise-or. 
> Example:
> SELECT FIRSTNAME, SURNAME FROM EMPLOYEE WHERE (STATUS & 1) > 0
> The Exception is:
> org.hibernate.QueryException: unexpected char: '&'

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira




More information about the hibernate-issues mailing list