Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CMP Question

 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, guys
I have a table abc_tbl. I want to write my own finder using EJB-QL. How can I conwert this SQL to EJB-QL?
select id from abc_tbl where id=? and abc_date=(select max(abc_date) from abc_tbl where id=?)
Thanx in advance,
Jamal
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Considering that both subselects and max functions are NOT part of standard EJB-QL the basic answer is probably "you can't".
Different vendors offer extensions to EJB-QL for their own projects so there's a chance you might be able to write this using them in your container, but it's a slim one.
Kyle
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Kyle for fast reply,
As I know th�re's MAX function in EJB-QL. id feld in my table is not unique. I had to choose the last (by edit date) record and give it to EJB. Do I have any chance to do it with CMP? Are there some pattern or solution or I had to do it with BMP?
Thanx in advance,
JAMAL
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB-QL only contains a MAX function in EJB 2.1 or in some vendor modifications for EJB 2.0. Details on that can be found here.
Instead of a subselect you might be able to do this as two queries. However, it turns out that Weblogic at least (see here) allows subqueries as a vendor-specific EJB-QL extension.
What server are you using, anyway?
Kyle
 
Jamal Hasanov
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using JBoss 3.2
Regards,
JAMAL
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic