Hello, Starting in Hibernate v6.2.3, I’ve got a regression on criteria queries when the root of the query is the child and the selection contains a field of the parent and a field of a junction of the child. The junction on the parent table is missing in the generated query. Considering the following entities:
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@DiscriminatorColumn(name = "type", discriminatorType = DiscriminatorType.STRING)
public abstract class AbstractParent {
@Id
@Column(columnDefinition = "uuid")
private final UUID id = UUID.randomUUID();
@Column
private String name;
}
@Entity
@DiscriminatorValue("CHILD")
public class Child extends AbstractParent {
@OneToMany(mappedBy = "child")
private final List<Attribute> attributeList = new ArrayList<>();
}
@Entity
public class Attribute {
@Id
@Column(columnDefinition = "uuid")
private final UUID id = UUID.randomUUID();
@ManyToOne
@JoinColumn
private Child child;
@Column
private String attributeName;
}
The following test fails with Hibernate 6.2.3 (and later) while it worked on v6.2.2
The given error is
We can see that in the generated query, the join on “parent” table is missing
select c1_1.name, a1_0.name
from child c1_0
// missing [inner join parent c1_1 on c1_0.id=c1_1.id]
left join attribute a1_0 on c1_0.id=a1_0.child_id
|