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.
When you do
, you create an implicit inner join between the tables.
You already have a left outer join between the tables:
So you just need to use the alias you assigned to this left joined entity:
Side note: your query would be much more readable if you used aliases systematically: