OpenJPA
  1. OpenJPA
  2. OPENJPA-2179

'distinct' and 'join' combinations lead lots of unneccessary sub-queries for @Embedded and @Lob fields

    Details

    • Type: Bug Bug
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.4.0
    • Component/s: kernel
    • Labels:
      None

      Description

      I have an Entity (Course) with a simple @Embedded field and a @Lob. I do not use any LAZY attribution on them!

      If I do a normal em.find, the entity will be loaded as a whole (all the fields, including the embedded and the lob will be fetched immediately).
      Sidenote: the Lecturer referred in the select is defined as
      @OneToMany(mappedBy = "course",
      cascade =

      {CascadeType.PERSIST, CascadeType.REMOVE, CascadeType.MERGE}

      ,
      orphanRemoval = true, fetch = FetchType.EAGER)
      @OrderColumn(name = "POSITION")
      private List<Lecturer> lecturers;

      The following selects DO work

      • "select c from Course c join c.lecturers l "
      • "select distinct c from Course c"

      The following selects create tons of subqueries! 1 separate sub-query for each @Embedded field, and also for each @Lob

      • "select distinct c from Course c join c.lecturers l "
      • "select distinct c from Lecturer l join l.course c"
      • "select c from Lecturer l join l.course c"

      This happens ONLY if I run this stuff against Oracle. In MySQL it seems to work properly.

      I'll try to create a unit test for it.

        Activity

        Mark Struberg created issue -
        Mark Struberg made changes -
        Field Original Value New Value
        Attachment OPENJPA-2179-test-1.patch [ 12525033 ]
        Mark Struberg made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        Mark Struberg made changes -
        Fix Version/s 2.4.0 [ 12325298 ]
        Fix Version/s 2.3.0 [ 12319463 ]

          People

          • Assignee:
            Mark Struberg
            Reporter:
            Mark Struberg
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Development