Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0, 5.2.0
    • Fix Version/s: 6.0.0.Alpha1, 5.2.8
    • Component/s: hibernate-core
    • Labels:
      None
    • Bug Testcase Reminder (view):

      Bug reports should generally be accompanied by a test case!

    • backPortable:
      Backport?
    • Last commented by a user?:
      true

      Description

      When doing an entity join on an entity type that involves multiple tables, currently the joins for the subclasses are missing in the SQL leading to a syntax error when e.g. using a sub- or super-type property with joined inheritance strategy.

      Take the following model

      @Entity(name = "Item")
      @Inheritance(strategy = InheritanceType.JOINED)
      public static class Item {
      	@Id
      	@GeneratedValue
      	private Long id;
      
      	@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
      	private Price price;
      
      }
      
      @Entity(name = "Price")
      public static class Price{
      	@Id
      	long id;
      
      	int amount;
      
      	String currency;
      }
      
      @Entity(name = "Book")
      @Table(name="BOOK")
      public static class Book extends Item {
      	private String title;
      
      	@ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)
      	private Author author;
      }
      
      @Entity(name = "Car")
      @Table(name="CAR")
      public static class Car extends Item {
      	@OneToMany
      	private List<Person> owners;
      
      	String color;
      }
      

      and the following query

      SELECT i1 FROM Book i1 JOIN Book i2 ON i1.price = i2.price
      

      The column for the property price is rendered in the ON clause into SQL, but the table join for the super type table item is missing.

        Attachments

          Issue links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: