I have two classes: A and B like this.
public Class A {
public B b;
// Setter and Getter
}
public Class B {
String code;
// Setter and Getter
}
I want to have a list of A loaded from database, sorted by B.code. But the problem is when an instance of A has null value for its b, it is ignored, and it is not loaded.
What should be done here? A brief hint would suffice.
UPDATED
Here is my code:
DetachedCriteria cr = DetachedCriteria.forClass(A.class, "a");
cr.createAlias("a.b", "b");
cr.addOrder(Order.asc("b.code"));
// something like cr.list();
By default
createAlias(String associationPath, String alias)generates an INNER join but here you need a LEFT_OUTER join so use the following instead :