My project was originally generated by seam-gen and the action "List" bean, OfficeViewList looks pretty much like it did when first generated.
The bean extends EntityQuery.
Now I want to order the results. What is the best way to do this?
Do I want to add some kind of "order by" class to my EJBQL? Or do I want to set the select order via
Here is the code that seam-gen generated (I have changed the RESTRICTIONS, but otherwise it's the same):
private static final String EJBQL =
"select officeView from OfficeView officeView";
private static final String[] RESTRICTIONS = {
"lower(officeView.addr1) like concat(lower(#{officeViewList.officeView.addr1}),'%')",
"lower(officeView.buildingId) like
concat(lower({officeViewList.officeView.buildingId}),'%')",
"lower(officeView.circuitId) like
concat('%',lower({officeViewList.officeView.circuitId}),'%')",};
public OfficeViewList() {
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(25);
}
The SQL translation is roughly
select * from office_view where order by office_id
I was thinking to use setOrder or setOrderColumn, like this
public OfficeViewList() {
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setOrderColumn("office_id");
setMaxResults(25);
}
but I can't quite figure out how to do it or whether either of these are appropriate. I can't find any documentation that really explains how to use these.
Or do I add some kind of "order by" clause to by EJBQL statement?
Or is there an annotation to add to my entity bean? or to the constructor?
Too many choices, not enough knowledge.
Thank you in advance.
TDR