Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

some questions about EJBQL  RSS feed

 
Stephen Lee
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am now using CMP for getting data from database. I find that it is qute unconvenient to use EJBQL to select records, comparing with SQL statement. e.g. it can't do the sorting task.
Now I have some questions to some EJBQL. For those questions, it is very easy to use SQL statement to do it (I don't want to use BMP, though I think BMP can do such tasks). How can I do such task by the use of CMP?
1) how can I select the largest value for a field of a table? (e.g. in SQL statement, SELECT MAX(col1) FROM table1) in EJBQL, I know that I can use SELECT OBJECT(o) FROM table1 and then use get the largest value in session bean, but it seems that it is quite slow.
2) how can I get a column only in a table? (e.g. in SQL statement, SELECT col1 FROM table1). However, in EJBQL, I can use SELECT OBJECT(o) FROM table1. I can obtain the whole record only, but I want to get a specific column only.
3) how can I count the number the records? (e.g. SELECT COUNT(*) FROM table1 where col1="test")
Thanks!
Stephen Lee
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!