Using the following entities:
If there exists a Foo entity, but there is no Bar entity with the same ID value as the Foo entity, then the following query, "from Foo where bar.id = ?1", should return null.
Instead, the query returns a Foo object with property bar set to null. This happens because the generated SQL does not include a join to the Bar entity table, as it should.
Notice that the query uses the "generic" ID named "id", not the actual ID (barId).