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

  • Home
  • SEARCH
  • 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 3806754
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T14:53:02+00:00 2026-05-19T14:53:02+00:00

I am porting an application for KodoJDO to Hibernate. I have a query that

  • 0

I am porting an application for KodoJDO to Hibernate.
I have a query that goes across 4 tables in the db, and 3 objects in the java code.

In English the query is Find the users that have entitlements in system X.

my JDOQL where clause called on the User object was
where entitlements.contains(ent) && (upper( ent.system.id ) = ‘EVPN’)

some sql that does the query is:

 select unique(u.id)
 from USER u, USERENTITLEMENT ue, ENTITLEMENT e, SYSTEM s
 where u.id = ue.userid
 and ue.entitlementid = e.id
 and e.systemid = s.id
 and s.id = 'evpn'

My best guess for HQL gives me an exception

org.hibernate.hql.ast.QuerySyntaxException: unexpected AST node: ( [select user from com.ebig.entity.User as user, com.ebig.entity.Entitlement as ent, com.ebig.entity.System as sys where  entitlements.contains(ent) and ent.system = sys and sys.id  = 'evpn']

the db is structured like this:

 User
   id

 UserEntitlement
   userid
   entitlementid

 Entitlement
   id
   systemid

 System
   id

the java code is structured as below:

 class User 
 {
    String id;
    Set<Entitlement> entitlements;
 }

 class Entitlement
 {
    String id;
    System system;
 }

 class System
 {
    String id;
 }

Update My final query that works

            hqlQuery = "select distinct user from User as user "+
        "inner join user.entitlements as entitlement inner join entitlement.system as system "+
        "where  system.id  = 'evpn'  AND mod(user.flags, 2) = 0  AND source = 1";

Yes I know I should use parameters, but I have a great many problems to solve, and will post pone that code for another day.

Another variation with an implicit inner join for entitlement to system

        hqlQuery = "select distinct user from User as user "+
        "inner join user.entitlements as entitlement "+
        "where  entitlement.system.id  = 'evpn'  AND mod(user.flags, 2) = 0  AND source = 1";
  • 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-19T14:53:03+00:00Added an answer on May 19, 2026 at 2:53 pm

    You should use joins :

    select distinct u.id from User u
    inner join u.entitlements as entitlement
    inner join entitlement.system as system
    where system.id = :evpn
    

    where :evpn is a named parameter that you have to bind.

    You must think in terms of objects and relationships between objects when doing HQL, and not in terms of tables, foreign keys and join tables.

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

Sidebar

Related Questions

I'm porting my application into Linux (from Windows). I have such code: char buffer[32]
I'm porting an application from WebForms to MVC. I have a WebForms UserControl that
Question appears during porting application from JSF 1.2 to JSF 2.0.3 (Mojarra). I have
Porting an application from C# (1.1 framework) to VB.NET (3.5 framework), and I have
I'm porting an application written in C++ from Windows to Linux. I have a
I'm porting my application from 32 bit to 64 bit. Currently, the code compiles
I'm porting an application from Java to C# and I'm facing a problem connected
I'm porting an application written in R that currently runs under Windows over to
I'm porting my application from WPF to Silverlight. The biggest problem is that my
We have developed Air application and next step it is porting this application to

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.