[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Issue with inheritance and join fetching

Before opening a bug, I want to share the issue I encounter with EL 2.3.x and 2.4.x. Maybe this has already been discussed but I didn't find previous

Assume I have a model with an Entity E1 with 2 onetoone on another Entity E2.
E2 is an abstract class (@Inheritance) extended by 2 Entites E21 and E22. They use a discriminator column. This case is a design choice and doesn't sound too messy (to me :-)).

When retrieving an E1 object (find by id, select in jpql or criteria), the two onetoone objects  are retrieved and values of their fields are correct.
As it triggers 3 sql queries, I want to optimize by join fetching the 2 onetoone : tried with jpql, criteria and JoinFetch annotation.
Now one of the two retrieved E2 objects  (whatever their subtypes) have incorrect fields : the two are the same !!
The sql generated contains distinct fields for each entity but values retrieved are badly affected in the objects.
Does someone know this bug ?
I can easily provide a test case.

Found another similar issue in case of a onetomany declared on E1 with the abstract E2 class (List<E2> myList). When join fetching this relation, elements in the list are badly casted (for example an E22 object in db becomes a E21 Java object. Verified when traversing the list with an instanceof).
Can easily provide a test case too.