• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

CMP Question

 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using JBoss 3.2
Regards,
JAMAL
 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic