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

Where clauses mapped on collections and entities need parentheses when used in conjunction

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.2.17, 5.1.15, 5.3.4
    • Fix Version/s: 5.3.5, 5.4
    • Component/s: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • Last commented by a user?:
      true
    • Sprint:

      Description

      Given the following mapping:

      @Entity
      public class Team {
          ...
          @OneToMany
          @Where( level = 'expert' or level = 'high' )
          private Set<Player> expertAndHighLevelPlayers;
      }
      
      @Entity
      @Where( active = 1 )
      public class Player
          ....
          private String level;
      

      Currently, the query for loading Team#expertAndHighLevelPlayers would be something like:

      active = 1 and level = 'expert' or level = 'high'

      Parentheses should be added to ensure that the separate clauses have the proper precedence, as in:

      ( active = 1 ) and ( level = 'expert' or level = 'high' )

      .

      This affects hbm.xml mappings as well.

        Attachments

          Issue links

            Activity

              People

              • Assignee:
                gbadner Gail Badner
                Reporter:
                gbadner Gail Badner
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: