If you have this entity:
@Entity
public class A {
@ManyToOne
@JoinColumn(name = "bField", nullable = true)
private B myBObject;
}
And I have a generic generator of Criteria who will do that:
Root<A> root = criteria.from(A.class);
root.get("myBObject").get("aFieldInB");
The problem is the following: the generated sql will contains a CROSS JOIN between A and B. But I would like that the generated sql will contains a LEFT JOIN between A and B.
How can I do that?
You must use a join(). In general it is better to always use a join() for relationships.
See, http://en.wikibooks.org/wiki/Java_Persistence/Criteria#JoinType
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With