I'm pretty sure this was introduced in 4.3.0.Final, but I can't trace it exactly. Suffice it to say this worked fine until recently, and I believe it was 4.3.0 that introduced it.
The facts:
-
abstract base class (TfrMonitor) uses InheritanceType.SINGLE_TABLE.
-
one of several subclasses (TfrRouteMonitor) has this:
@ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="subscriber_route_id",nullable=false) private SubscriberRoute subscriberRoute;
-
when I do a "subclass agnostic" query (i.e. querying for the base class, not a specific subclass), such as:
select t from TfrMonitor t where t.id = 1
...it now produces SQL that has an INNER JOIN on the subscriber_route table. This used to do a LEFT JOIN.
I can work around this by removing the nullable=false on the @JoinColumn on the subclass, such as:
@ManyToOne(fetch=FetchType.EAGER) @JoinColumn(name="subscriber_route_id") private SubscriberRoute subscriberRoute;
If I've been abusing/misusing JPA all this time, that's fine and I want to know the right way to do this, but this did work just fine – for years. Literally since around 2006 this has been working just fine even with the nullable=false on the subclass relationship.
Something recently changed that is forcing the INNER JOIN. Please fix this so that it recognizes that despite the non-nullability and eager fetch, the relationship is on a subclass, and does a LEFT OUTER JOIN.
Thanks!
|