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

MultiValuedTrasveralAttempt not evaluated when there is another field with the same name in the path

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 2.4.1
    • None
    • kernel
    • None

    Description

      Problem

      MultiValuedTrasveralAttempt not evaluated when there is another field with the same name in the path.

      Steps:

      1. Create a client entity as:

      @Entity
      public class Client {
      
          @Id
          @GeneratedValue
          private Integer id;
      
          @OneToMany
          private Collection<Product> products;
      
      ...
      

      2. and a Product:

      @Entity
      public class Product {
      
          @Id
          @GeneratedValue
          private Integer id;
      
          @ManyToOne
          private Client client;
      
          private Boolean deleted = false;
      
      ...
      

      3. Run this query:

      SELECT DISTINCT c
      FROM Client c JOIN FETCH c.products
      WHERE c.products.deleted = false

      Result is: "JPQL does not allow traversal through multi-valued relation path. Try join instead"

      4. Add a deleted field to the client:

      private Boolean deleted;
      
      

      5. Run the query again

      No errors!

      Expected result:

      Same exception when client have a deleted field

      org.apache.openjpa.kernel.exps.AbstractExpressionBuilder.traversePath is finding the wrong deleted field in the c.products path (the client.delete) and isMultiValuedTraversalAttempt is never evaluated

      Attachments

        Activity

          People

            Unassigned Unassigned
            gonzalo Gonzalo Diethelm Guallar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: