| It's not possible to use the `TYPE` function on a leaf type of a table per class hierarchy. Let's consider the following model
@Entity(name = "Father")
public class Father extends Parent {
@Column
String fathersDay;
}
@Entity(name = "Mother")
public class Mother extends Parent {
@Column
String mothersDay;
}
@Entity(name = "Parent")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
public abstract class Parent {
@Id
public Long id;
}
When querying SELECT TYPE(f) FROM Father f it will produce invalid SQL, something like
select
unionsubcl0_.clazz_ as col_0_0_
from
Father unionsubcl0_
where
unionsubcl0_.id=-1
The AbstractEntityPersister#getDiscriminatorColumnReaderTemplate for a leaf subtype should return the type index as constant instead of the invalid column reference. |