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.
|