Hibernate Soft Delete on Many to Many Creating Strange Query on Find

Description

I am trying to implement annotation based soft delete in hibernate, in this case on a many-to-many relationship. Up until now it has worked very well, but I encountered an odd condition that I am wondering if it's a bug or I am simply misinterpreting the usage.

The problem comes when I try to execute a find on an entity (A) and the soft-delete-where for the child (B) is injected to the overall where for the base entity in the actual SQL output of the find. The end result of this is if the A does not have any Bs, the soft-delete-where causes the main find query to return no As, even if they exist.

Here is an example of the annotations used in A (simplified for readability):

And here are the annotations used in B (also simplified for readability):

Here is the SQL output from logs from a simple getSession().get(List.class, id);

I don't know if maybe I'm looking at it all wrong, but just because a child is not active should not mean a parent doesn't exist. My expectation would be one of two things, either it should be putting the active in the ON of the join, or it should be splitting this into two queries (one for the List and one for the children).

I tested removing the ( authgroup2_.isActive = 1) from the WHERE and it returns results, where this returns none.

Any help in either understanding that I am using this wrong, or a possible future fix would be greatly appreciated.

Environment

Java 8
Spring 4.3.3
Hibernate 5.2.5 Final

Status

Assignee

Unassigned

Reporter

Cliff Casey

Fix versions

None

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure