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 8243465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T21:31:49+00:00 2026-06-07T21:31:49+00:00

I am having tough time creating a HQL query that checks if a list

  • 0

I am having tough time creating a HQL query that checks if a list of records ‘a’ of table ‘X’ is included within another list ‘b’ of the same table ‘X’.

Here is an example i am using:

select r 
from Role r 
where (
    select p 
    from Permission p 
    where p.name = 'test') in elements(r.permissions)

Now this query is just as an example, to clarify a bit, each role has 1 or more permission.

Now here’s what happen, if the the subselect (permission p) returns 1 row, all work fine. But if more are selected, the query fails, since I am trying to check if a list is within a list…

I am sure I am missing something here, so please any help would be appretiated.

Thanks

  • 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-06-07T21:31:51+00:00Added an answer on June 7, 2026 at 9:31 pm

    Maybe something simpler exists, but I’ve not found it:

    select r from Role r where not exists (
        select p.id from Permission p 
        where p.name = 'test'
        and p.id not in (select p2.id from Role r2 inner join r2.permissions p2
                         where r2 = r))
    

    To make it clearer, this query checks that there is no permission of name ‘test’ that is not in the role permissions, which is the same as saying that all permissions with name ‘test’ are in the role permissions.

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

Sidebar

Related Questions

I have been having a tough time getting an attendance table for a classroom
I'm having a tough time figuring out how to have a select list drive
I am having a tough time understanding why the Scala compiler is unhappy about
I am reaching a bottleneck on my application and having a tough time finding
I'm pretty new to Backbone and Marionette and am having a tough time getting
I'm without my Java reference book and I'm having a tough time finding an
I'm having a real tough time diagnosing a 500 error from my application running
I'm having a really tough time getting XMPPFramework to work. I've followed every direction
Having another tough one here guys, basically I would like to check if a
I'm having a tough time formatting this WordPress widget to look good. http://healthybodyguru.com/ It's

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.