I want to perform a LEFT OUTER JOIN between two tables using the Criteria API. All I could find in the Hibernate documentation is this method:
Criteria crite
Sdavids answer's API is deprecated
now. Its updated version is
....createAlias("employee", "emp", JoinType.LEFT_OUTER_JOIN)
If you need to left join on the products table just do:
.....createAlias("products", "product", Criteria.LEFT_JOIN);
A join is in the SQL request. It can't be lazy.
With Hibernate, to retrieve lazily this data, just exclude it from the HQL request. Then, when you access the getters on your entity (if your Session is still open), it will be loaded automatically (you don't have to write that part of the request).