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

A query with LEFT FETCH JOIN returns incorrect results.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.1, 2.2.2, 2.2.1.1, 2.3.0, 2.4.0
    • 2.1.2, 2.2.1.1, 2.2.3, 2.4.0
    • query
    • 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

        1. OPENJPA-2475-2.1.x.test
          11 kB
          Heath Thomann

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: