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. |