The eclipselink version that we are using is 2.3.1.v20111018-r10243.
We are having 3 entities , say A,B,C with (C extends A and B extends A) all in the Isolated (Uow) session.
We have disabled fetching of sublcasses when Fetching A , using the following property (QueryHints.INHERITANCE_OUTER_JOIN set to false ) or (Within classDescriptor set InheritancePolicy().setShouldReadSubclasses to false for class A).
We are able to successfully fetch entity A using the above approch, but when we try to traverse to any of the (LAZY)relationships of A, they are returning null.
The same works find when we dont disable Inheritance-Outer-Join. Is this issue with eclipselink. Any help or pointers on this greatly appreciated.
INHERITANCE_OUTER_JOIN affects all queries to that entity tree. This would affect mappings where the type is the A superclass, but in the database be of type B or C, returning null since there is no A for that reference. Can you provide the mapping and what gets returned when INHERITANCE_OUTER_JOIN isn't set?
"Set QueryHints.INHERITANCE_OUTER_JOIN to false" and "set InheritancePolicy().setShouldReadSubclasses() to false" have different effects.
"Set QueryHints.INHERITANCE_OUTER_JOIN to false" - which is default - will issue separate query for each subclass:
"set InheritancePolicy().setShouldReadSubclasses() to false" only returns the root class instances which match the search criteria:
In my test case, Director extends Manager which extends Employee, Employee has a relationship to Dog.
In the database, there are one instance of Director, Manager and Employee, all three of them have id set to 'Bob', and all have a related Dog instance.
The I query with "SELECT o FROM Employee o WHERE o.id = 'Bob'"
With QueryHints.INHERITANCE_OUTER_JOIN set to false, I saw three queries issued against Director, Manager and Employee tables, and returned 3 instances of 'Bob' as expected, and navigating to Employee.getDog() returned the Dog instance correctly.
With InheritancePolicy().setShouldReadSubclasses() set to false, there is one query issued against the Employee table and returned one Employee instance only, and navigating to Employee.getDog() returns the Dog instance correctly.
So if your intention is to bring back the root class instances only, then "set InheritancePolicy().setShouldReadSubclasses() to false" should work for you.
Or are you trying to bring back all three instances as Employee without the subclasses' attributes and relationships being populated?