[jboss-user] [JBoss Seam] - query order by extension and restrictions

jamesjmp do-not-reply at jboss.com
Thu Aug 2 07:25:22 EDT 2007


hi!
setting the order of a query result by configuration may be done this way:

<framework:entity-query name="jmpRstReport4"
    ejbql="select rstReport from RstReport rstReport"
    order="code desc"/>    

I wonder if there is a way of doing the same by extension.
I have a POJO DAO this way:

@Name("rstReportList")

private static final String[] RESTRICTIONS = {
            "lower(rstReport.rstStatus.description) like concat(lower(#{rstReportList.rstReport.rstStatus.description}),'%')",
            "lower(rstReport.rstStatus.description) not like lower(#{'TEMPLATE'})",
            "lower(rstReport.shortDescription) like concat(lower(#{rstReportList.rstReport.shortDescription}),'%')",
        };        

public class RstReportList extends EntityQuery {
@Override
	public String getEjbql() {
		return "select rstReport from RstReport rstReport";
	}
}

Apart from adding "order by code desc" to the ejbql code, how may I set the order by extension?

On the other hand, if 2 pages need the same query but with different restrictions. the best way would be to define 2 queries, each one with its proper restriction/s, or is there a way to set restrictions dinamycally by means of a parameter or something like that?
For instance I have a component called "myQuery". Once I want to use it with restriction 1, but in other page I want to use it with restriction 2 and not applying 1. is that possible? Defining 2 queries (each with its restriction) works fine and solves the problem. but is that the best way?

thanks in advance!


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4070057#4070057

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4070057



More information about the jboss-user mailing list