aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes CMP Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "CMP Question" Watch "CMP Question" New topic
Author

CMP Question

Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
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

Joined: Aug 10, 2001
Posts: 3892
    
    5
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

Joined: Jan 08, 2002
Posts: 411
I'm using JBoss 3.2
Regards,
JAMAL
 
 
subject: CMP Question