[jboss-user] [EJB 3.0] - @NamedQuery and setting orderBy as a parameter?
rocken7
do-not-reply at jboss.com
Tue Jan 30 15:28:29 EST 2007
Lets say you have a ton of records in a content table, and a lot of criteria to determine appropriate content.
How would you specify the orderBy and sort on a @NamedQuery, say as a parameter or by overriding the default orderby etc. ?
I know i can annotate a bunch of @NamedQuery's but do I have to go and do the same huge query for every different orderBY and sort ? This will end up with at least 8-columns x 2 (asc|desc) = 16 named-queries, then if we alter the criteria, add another 16 named-queries. Its cr8zy.
It just seems to be begging for this simplicity:
Query q = em.createNamedQuery("findHottestContent");
| q.setParameter("orderBy", "viewsWeekly desc");
|
Too many records to just load into a collection and post-sort like most documentation suggest doing, thats why there is an "order by" clause in SQL, thats what databases are good at.
I know I can do a native query but then I end up with cache issues.
Any ideas or coming patches to solve this?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4008499#4008499
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4008499
More information about the jboss-user
mailing list