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
{code:java} @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; } {code}
When querying {{SELECT TYPE(f) FROM Father f}} it will produce invalid SQL, something like
{code:sql} select unionsubcl0_.clazz_ as col_0_0_ from Father unionsubcl0_ where unionsubcl0_.id=-1 {code}
The {{AbstractEntityPersister#getDiscriminatorColumnReaderTemplate}} for a leaf subtype should return the type index as constant instead of the invalid column reference. |
|