Hello, I am facing an issue where I need to incorporate a right join in the Criteria API. Due to the project limitation I can’t use Hibernate 6+.
I want to have the fsmth following:
final var groupJoin = root.join("Some entitiy" JoinType.RIGHT);
It appears that Hibernate does not support this type of join.
Any workarounds would be greatly appreciated.
Here is my basic entity structure:
@Entity
public class Label {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToMany(fetch = FetchType.LAZY, mappedBy = "label")
private Set<LabelSupplier> labelSuppliers = new HashSet<>();
// Additional fields and methods...
}
@Entity
public class LabelSupplier {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne
@JoinColumn(name = "label_id", nullable = true) // Notable for allowing nulls
private Label label;
// Additional fields and methods...
}
Actually, my task is to return the duplicated parent for each child. You can suggest querying a parent in the given scenario, then iterating over a collection of children, placing all this information into a resource dto, and ultimately returning it to the client. However, this approach is not viable for me. In such a scenario, another issue could arise when the client attempts to set the size parameter, specify a query URL size parameter, or utilize some Spring Boot pagination features.
In conclusion, I would like to retrieve each LabelSupplier If there is no Label for certain LabelSupplier - just return LabelSupplier with null label