-
1. Re: Listing Records in Order
shs96c May 11, 2002 8:20 PM (in response to david_cohoon)Why not create the value objects using JDBC? You can then use normal SQL and order things appropriately using the database.
Assuming that you're in the situation where you have lots of reads, and few writes this should be pretty fast, and when you need to write, use a finder to get the EJB that you'll be modifying. -
2. Re: Listing Records in Order
sgturner May 12, 2002 5:25 PM (in response to david_cohoon)If you are using 3.0, you can use JbossQL which is an extension of Ejb-QL. JBossQL lets you have order by clauses in the expected way. "select object(o) from blah order o.foo". If you are working in 2.4.x, the question becomes one of scalability. If there are only a few different order by clauses, put in finder methods. If there are a lot of order by possibilities, I would manually sort them, but not in the presentation layer, sort them in the session bean layer.
-
3. Re: Listing Records in Order
timdeboer Jun 20, 2002 12:51 PM (in response to david_cohoon)If you're planning to sort on the client side just remember that there may come a time when you want to chunk your returned collections. There is no elegant way of doing this that i have found to date without first ordering on the database (at least with oracle there is not.. If anybody would like to challenge this i look forward to your contributions!)
As a result, you'll end up querying the following data:
0,1,2,3,4,5,6,7,8,9
and getting back the following 2 pages:
page 1: 1,3,4,5,7
page 2: 0,2,6,8,9
Tears well up just thinking about it ;) -
4. Re: Listing Records in Order
crackers Jun 20, 2002 4:18 PM (in response to david_cohoon)You can also make your objects implement the Comparable interface and put them into a TreeSet - viola! Instant sort.