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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:50:49+00:00 2026-05-14T23:50:49+00:00

select x from X x where x.a.id = :a_id –> Always 0 objects selected

  • 0

select x from X x where x.a.id = :a_id –> Always 0 objects selected

Why does the above JPQL statement not work, but the one below work?

select a from A a where a.id = :a_id –> a_obj
select x from X x where x.a = :a_obj –> Always correct number of objects selected

Neither query throws an exception during execution, but a different number of results are obtained.

Thanks


Update

I tried the following queries by using joins:
select x from X x, x.a a where x.a.id = :a_id –> TopLink exception for unexpected token

and this:
select x from X x JOIN x.a a where a.id = :a_id –> Always correct number of objects selected

With the latter query, I have solved the initial problem at hand. However, now I have got two queries which should work, but for some reason don’t.

select x from X x where x.a.id = :a_id –> Always 0 objects selected
select x from X x, x.a a where x.a.id = :a_id –> TopLink exception for unexpected token

Has anyone else encountered similar behaviour?

  • 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-14T23:50:50+00:00Added an answer on May 14, 2026 at 11:50 pm

    I think you have to also bring in entity a in the first example so that it’s attributes are visible.

    Something like

    select x from X x join fetch x.a where x.a.id = :a_id
    

    (I don’t use JPA, I stick to HQL, so this is untested, unproven and comes without a money-back guarantee.)

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

Sidebar

Related Questions

I have a query like this SELECT user_id FROM user WHERE user_id NOT IN
SELECT * FROM Table_A LEFT JOIN Table_B ON (Table_A.A_ID = Table_B.A_ID) INNER JOIN Table_C
My query is quite simple: select a.ID, a.adres, a.place, a.postalcode from COMPANIES a, COMPANIES
i have this SELECT COUNT(1) cnt, a.auther_id FROM `posts` a LEFT JOIN users u
I have a query: SELECT ID FROM requests WHERE date <operator> <expression> I need
I have a MySQL query SELECT * FROM 'redirect' WHERE 'user_id'= \''.$_SESSION['user_id'].' \' ORDER
If I have a query such as : select * from tbl where id
I've got a mysql query like this: SELECT A.ID, A.NAME, B.ID, B.NAME FROM table1
I have a complex MySQL problem. SELECT * FROM banners, content_id_country, languages WHERE content_id_country.content_id
I have a following HQL query: SELECT s.id FROM stack s WHERE s.category is

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.