Is it somehow possible to create a criteria query that performs an outer join on another entity if that entity is not mapped?
I know that an inner join is possible when you do a cross join and add the join condition manually. It would look like this:
CriteriaBuilder cb = getCriteriaBuilder();
CriteriaQuery<Tuple> cq = cb.createTupleQuery();
Root<Car> car = cq.from(Car.class);
Root<Color> color = cq.from(Ccolor.class);
cq.where(cb.equal(car.get("colorUuid"), color.get("uuid")));
However I need the behaviour of an outer join in my case.
So let's say I have these entities:
class Car {
@Column(name="color_uuid")
private String colorUuid;
}
class Color {
private String uuid;
private String name;
}
Lets say Color is optional and that's why I need an outer join. The SQL would look like
SELECT * from car LEFT OUTER JOIN color ON car.color_uuid = color.uuid;
Can I do this with Criteria?