Joined subclass query is invalidly inner joining when it should outer join

Description

I discovered the following problem trying to upgrade from hibernate 3.5 to 4.3. For background, we currently have a database schema that has a family of tables that use the joined subclass inheritance model.

The structure more or less goes like this:
SuperParent has two children: `Custom` and `Ldap`. Let's ignore `Ldap`. `Custom` has a child named `Role`, which has a `@ManyToOne(nullable=false)` association with `Permissions`.

The problem is this: When I call `entityManager.find(Custom.class, id)`, it is over-zealously joining the permissions table with an `inner join`, which behavior begins at 4.3.0.Final. When I revert back one version to 4.2.14, it properly creates an `outer join` on the permissions table.

I expect the reason behind the inner join is the tightness of relationship with `Role` since it is non-nullable? But since what I am looking for is actually a `Custom` and not a `Role`, and so there will never be any permissions references to it, and so the lookup will always fail.

PS. My workaround for now is to only upgrade to 4.2.14, and additionally to hopefully undo some of this unnecessary hierarchy.

Environment

MS SQL Server
Hibernate versions 4.3.0 - 4.3.5 all exhibit this behavior; 4.2.14 is fine.

Activity

Show:
Gail Badner
July 22, 2014, 5:56 AM

This duplicates HHH-8980, which was fixed in 4.3.6.

Matt Hauck
July 22, 2014, 6:02 AM

Excellent, thanks!

Brett Meyer
April 22, 2015, 9:14 PM

Closing rejected issues.

Assignee

Gail Badner

Reporter

Matt Hauck

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Components

Affects versions

Priority

Major
Configure