Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-2475

A query with LEFT FETCH JOIN returns incorrect results.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.1, 2.2.2, 2.2.1.1, 2.3.0, 2.4.0
    • Fix Version/s: 2.1.2, 2.2.1.1, 2.2.3, 2.4.0
    • Component/s: query
    • Labels:
      None

      Description

      Take the following two entities:

      @Entity
      public class DepartmentTest{
      @Id
      private String primaryKey;

      @OrderBy("name")
      @OneToMany(mappedBy = "departmentTest")
      private Set<PersonTest> persons = new HashSet<PersonTest>();
      ...........

      @Entity
      public class PersonTest {
      @Id
      private String primaryKey;

      @ManyToOne
      @ForeignKey
      private DepartmentTest departmentTest;

      private String name;
      .....

      With these entities, take this JPQL:

      "SELECT DISTINCT dept FROM DepartmentTest dept LEFT JOIN FETCH dept.persons";

      Depending on the data in the database (the order is important, see the provided test), this query can return a results set where some of the 'persons' are missing.

      Thanks,

      Heath Thomann

        Attachments

          Activity

            People

            • Assignee:
              jpaheath Heath Thomann
              Reporter:
              jpaheath Heath Thomann
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: