Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6843463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:14:52+00:00 2026-05-27T00:14:52+00:00

I´m giving up and ask the community … In my project, I´m using Hibernate

  • 0

I´m giving up and ask the community …

In my project, I´m using Hibernate 3.6.4.Final and a custom sql dialect:

public class ServiceAppMySQL5InnoDBDialect extends MySQL5InnoDBDialect {

    public ServiceAppMySQL5InnoDBDialect() {
        super();
        registerFunction("bitwise_and", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "(?1 & ?2)"));
        registerFunction("hasflags", new SQLFunctionTemplate(StandardBasicTypes.BOOLEAN, "?1 & ?2 = ?2"));
    }

}

Using the hasflags method in a HQL query fails.
Here is the query:

Query q = em
        .createQuery(
            "SELECT o FROM "
            + entityClass.getName()
            + " o WHERE hasflags(o.status, :status) AND o.email = :email")
        .setParameter("email", username)
        .setParameter("status", status.getBitmask());

The error:

Caused by: org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: ( near line 1, column 50 [SELECT o FROM tv.px.domain.Owner o WHERE hasflags(o.status, :status) AND o.email = :email]
    at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:54)
    at org.hibernate.hql.ast.QuerySyntaxException.convert(QuerySyntaxException.java:47)
    at org.hibernate.hql.ast.ErrorCounter.throwQueryException(ErrorCounter.java:82)
    at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:261)
    at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:185)
    at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:136)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
    at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
    at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
    at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
    at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
    at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
    at org.hibernate.ejb.AbstractEntityManagerImpl.createQuery(AbstractEntityManagerImpl.java:272)

So, it seems as if the function is not properly registered. I´ve done this several times with older Hibernate versions and it worked this way all the time.

Just in case someone asks this: yes, I configured Hibernate to use the dialect:

<persistence-unit name="persistenceUnit"
    transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>
    <properties>
        <property name="hibernate.dialect" value="tv.px.persistence.hibernate.ServiceAppMySQL5InnoDBDialect" />

        <!-- and so on -->
    </properties>
</persistence-unit>

Edit: In the SELECT clause I can use registered functions without problems, but not in the WHERE clause.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:14:53+00:00Added an answer on May 27, 2026 at 12:14 am

    I have a similar problem. It works if you modify the where clause to:

    hasflags(o.status, :status) = true
    

    I need it to work without that, and my search for it brought me here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the best way to construct an #ask query using semantic properties from
I have 2 questions to ask regarding opening files (any kind of files) using
After reading and try'n'error for days, I´m giving up and ask for help. <
The layout editor is giving me StackOverflowErrors which ask me to exit eclipse everytime
I'm sorry, I don't know how to ask this question without giving you the
I integrated facebook app using sharekit by giving the FB Secret key and session
If I have this code: class TestBrowser : WebBrowser { public TestBrowser() { Panel
I think the best way to ask my question is by giving an example.
Eclipse is giving me an error when defining a top level class with the
sorry to ask so many questions about SQL but I am doing exercises that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.