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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:45:28+00:00 2026-05-28T02:45:28+00:00

I am struggling to convert this sql query SELECT feature.*, rolefeature.roleId, rolefeature.permission FROM feature

  • 0

I am struggling to convert this sql query

SELECT feature.*, rolefeature.roleId, rolefeature.permission 
    FROM feature 
        Left JOIN rolefeature 
            ON feature.featureId = roleFeature.featureId 
                and roleFeature.roleId = ?

which works fine.

to JPQL. I have this

select f, rf.role.roleId as roleId, rf.permission 
    from Feature f 
        LEFT JOIN f.roleFeatures rf 
            and rf.role.roleId = :roleId

but it seems to complain about the AND keyword. I’m at a bit of a loss. If I use a WHERE instead of an AND, it does not return the correct data

  • 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-28T02:45:28+00:00Added an answer on May 28, 2026 at 2:45 am

    First of all, the and clause makes no sense here. You need a where clause.

    Second, querying on rf.role implicitely makes an inner join between RoleFeature and Role. You would see it by inspecting the generated SQL. You need to do a second left join to access Role.

    Third, if you put the restriction on the role ID in the where clause, the left join will become an inner join. So you need the equivalent of the on clause in JPQL. I don’t think JPQL has that, but Hibernate supports it using the with keyword:

    select f, role.roleId as roleId, rf.permission 
    from Feature f 
    left join f.roleFeatures rf 
    left join rf.role role with role.roleId = :roleId
    

    Maybe you can simulate it with

    left join rf.role role
    where role.roleId is null or role.roleId = :roleId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a simple SQL query, but im struggling to replicate in LINQ select
struggling to get my head round this. i want to convert the following sql
I'm struggling to convert the following (simplified) HQL to QueryOver: select subscription from Subscription
I have the following in linq-to-entities clientprojects = (from p in this.SAPMappingEntities.SAP_Master_Projects join c
I'm using a SELECT statement in T-SQL on a table similar to this: SELECT
I am struggling to convert a url to a nested tuple. # Convert this
I have been struggling to get this right! Can anyone help me to convert
I ma struggling with this mathematical-based query. I have the difference in seconds between
I'm really struggling to convert this timestamp to a nice formatted date string. Here's
I need help with a SQL that will convert this table: =================== | Id

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.