Uploaded image for project: 'Hibernate ORM'
  1. HHH-7321

HQL: Combining a CROSS JOIN with a LEFT JOIN which requires a WITH clause triggers an exception.

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects versions: 4.1.0, 4.1.3, 5.0.0.Final
    • Fix versions: 5.1.0
    • Components: query-hql
    • Environment:
      JDK 7.0 Update 4
      JBoss AS 7.0.1 Final
    • Last commented by a user?:
      true
    • Sprint:

      Description

      I'm trying to combine a CROSS JOIN with a LEFT JOIN. The last one requires a WITH clause that references one of tables used in the CROSS JOIN. For example, I want to list students, questions of an exam, and their answers to them. Some answers may not exist, thus I'm using a LEFT JOIN:

      SELECT s.studentId, q.questionId, sa.answer
      FROM Student s, Question q
      LEFT JOIN s.studentAnswerList AS sa WITH sa.question.questionId = q.questionId

      This causes an exception: javax.ejb.EJBException: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: with-clause referenced two different from-clause elements .

      The entities are really simple. These are their attributes:

      • Student.studentId
      • Question.questionId
      • StudentAsnwer.studentAnswerId
      • StudentAsnwer.studentId
      • StudentAsnwer.questionId
      • StudentAsnwer.answer

      I've been suffering from the same problem in both 3.x and 4.x versions of Hibernate.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                8 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: