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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:27:34+00:00 2026-06-15T23:27:34+00:00

I have two tables TableA , TableB with many to one relationship defined in

  • 0

I have two tables

TableA, TableB with many to one relationship defined in hbm.xml

Example:

TableA

Because uni-directional relationship (only TableA to TableB) there are no entries in TableB hbm.xml related to TableA

Now the issue is, TableA may have null values for columnIDFromTableA and when I query TableA, these rows also should showup apart from matching rows from TableB, but it is not working.

The query I have is:

select column1, column2, tableA.tableB.someColumn from TableA tableA left outer join tableA.tableB as tabB where column1  Like '%someval%' 

Above query returning ZERO rows.

As soon as I remove column related to tableB (in this case tableA.tableB.someColumn) from query, I am getting expected results

select column1, column2 from TableA tableA left outer join tableA.tableB as tabB where column1  Like '%someval%' 

above query returning expected results.

Any help would be appreciated.

  • 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-15T23:27:35+00:00Added an answer on June 15, 2026 at 11:27 pm

    When you do

    tableA.tableB.someColumn
    

    , you create an implicit inner join between the tables.

    You already have a left outer join between the tables:

    from TableA tableA left outer join tableA.tableB as tabB
    

    So you just need to use the alias you assigned to this left joined entity:

    select column1, column2, tabB.someColumn 
    from TableA tableA 
    left outer join tableA.tableB as tabB 
    where column1  Like '%someval%'
    

    Side note: your query would be much more readable if you used aliases systematically:

    select tableA.column1, tableA.column2, tableB.someColumn 
    from TableA tableA 
    left outer join tableA.tableB as tableB 
    where tableA.column1 like '%someval%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables connected with one to many relationship. Parent Table is a
android noob... I have two tables, with a one to many relationship between country_tbl
I have two simple classes which reference each other as a one-to-many relationship defined
I have two tables in a one to many relationship. (products and qty break
I have two tables, Campaign and Advert with a one to many relationship. During
I have two tables, in one to many relationship (Quizzes, Comments): a Quiz can
Let's say I have two tables with a one-to-many relationship. I want to create
I have two tables with a many to one relationship which represent lots and
I have two tables that have a one-to-many relationship. The primary key of table
I have two tables with a relationship one to many, lets say I have

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.