• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

how can we do a "order by" with ejb?

 
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we can use home business method to get a list of all the users(CMP Entity bean), but how can we order them, say by their first name, ID since there is no "order by" in EJB QL?
Thank you in advance
 
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.Collections.sort( list, comparator );
 
Yi Meng
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Rufus BugleWeed:
java.util.Collections.sort( list, comparator );


So the process will be
1. use home business method to get a Collection/Set of users
2. Convert to List
3. Apply java.util.Collections.sort( list, comparator );
is it expensive to do all these in this way? As in plain jdbc, we could solve this problem simply by adding a "order by " clause in the sql command ....
Anyone can share with me your opinion why EJB QL does not include a "order by" clause? What are the design issues involved? Is it because of cmr field?
[ March 09, 2004: Message edited by: Yi Meng ]
 
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know why Sun didn't include it in the spec, but you'll find some containers provide their own EJB-QL extensions to deal with stuff like this.
 
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Reid M. Pinchback:
I don't know why Sun didn't include it in the spec, but you'll find some containers provide their own EJB-QL extensions to deal with stuff like this.


EJB QL has been enhanced in EJB 2.1 with the addition of aggregate functions, the ORDER BY clause , and other new features and clarifications.
for e.g. EJB 2.1 does add some functions to the SELECT clause that EJB 2.0 is missing including COUNT(), SUM(), AVG(), MAX() and MIN().
(Refered from Rachard Monson-Haefel's Enterprise Java bean forthcoming 4th edition)
 
Ranch Hand
Posts: 1066
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Rashmi Tambe:
(Refered from Rachard Monson-Haefel's Enterprise Java bean forthcoming 4th edition)


Are there any review chapters of the new book on EJB2.1 still available?
 
Yi Meng
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Vish Kumar:

Are there any review chapters of the new book on EJB2.1 still available?


I dun have review chapters of his new book, but you may find this informational...
http://www.theserverside.com/articles/article.jsp?l=MonsonHaefel-Column1
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Vish Kumar:

Are there any review chapters of the new book on EJB2.1 still available?


No, i'ts not available now...it was there on serverside.com few weeks ago. If you want, i can mail you the zip. there were 13 chapters available on serverside for public review. I have all of them.
 
Yi Meng
Ranch Hand
Posts: 270
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would appreciate if you could send me a copy ...
mengyi@illion.net
 
Rashmi Tambe
Ranch Hand
Posts: 418
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Yi Meng:
I would appreciate if you could send me a copy ...
mengyi@illion.net


I have uploaded the chapters
my web page. download it from there.
 
Ranch Hand
Posts: 241
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Yi Meng:

So the process will be
is it expensive to do all these in this way? As in plain jdbc, we could solve this problem simply by adding a "order by " clause in the sql command ....
[ March 09, 2004: Message edited by: Yi Meng ]


I think it is not expensive since the selects cost the same and the resultSet is sort in primary memory
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic