This discussion is archived
2 Replies Latest reply: Oct 4, 2012 2:42 PM by 781795 RSS

Problem disabling Inheritance-Outer-Join  on Isolated entities.

864861 Newbie
Currently Being Moderated
Hi,

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.

Thanks,
Sriram
  • 1. Re: Problem disabling Inheritance-Outer-Join  on Isolated entities.
    cdelahun Pro
    Currently Being Moderated
    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?

    Best Regard,
    Chris
  • 2. Re: Problem disabling Inheritance-Outer-Join  on Isolated entities.
    781795 Newbie
    Currently Being Moderated
    Sriram,

    "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:
    http://www.eclipse.org/eclipselink/api/2.3/org/eclipse/persistence/config/QueryHints.html#INHERITANCE_OUTER_JOIN

    "set InheritancePolicy().setShouldReadSubclasses() to false" only returns the root class instances which match the search criteria:
    http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Entities/Inheritance#Reading_Concrete_Superclasses

    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?

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points