• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

EJB-QL and operators

 
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have the operators UNION and NOT been adopted yet in EJB-QL ?
regards
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
NOT is already part of EJB-QL, but UNION isn't (at least in 2.0) and I doubt it will because UNION is not that helpful with objects, I think.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJB-QL is used to handle Business Rules.
How would you code up the following in EJB-QL.
1% Discounts apply to Customers who have bought Books in the any quarter
(Qx), 10% discounts apply to customers who have bought Books in quarters (Q1, Q2 ,Q3) and the total value exceeds 50$.
Customers may only be applicable to 1 discount.

With SQL it would be quite easy to exclude groups by NOT EXISTS and include Groups by the UNION operator.
How would you code these sets of rules in EJB-QL ?
regards
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, I don't think I'll be that active today...
Anyway, I'll have to say that you encode all of those rules in EJB-QL, yet. For example, the SUM() function will be introduced in EJB 2.1 (still a public draft).
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anyway, I'll have to say that you encode all of those rules in EJB-QL, yet.


Did you mean ...
"Anyway, I'll have to say that you CAN'T encode all of those rules in EJB-QL, yet."


First of all, I don't think I'll be that active today...


What!Taking a break ? Well deserved!
regards
[ September 20, 2003: Message edited by: HS Thomas ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, that's what I meant to say. See why I need(ed) the break...
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

"Anyway, I'll have to say that you CAN'T encode all of those rules in EJB-QL, yet."


And no SUM function or UNION.
This is either a glaring or deliberate ommission ! Which?
regards
[ September 21, 2003: Message edited by: HS Thomas ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
SUM (and AVG etc) is coming in the 2.1 version of the specification, but UNION is not as far as I know.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I believe that's too far down the line.
What options do you have if you were implementing the above rules with EJB ?
I suppose you'd derive that information from two simpler Entity beans.
There must be a finder (?) method that is the equivalent of UNION.
Creating and developing related CMP entity beans. Related entity beans are sets of EJB components that represent complex data from multiple database tables that have primary/foreign key relationships. There is a new wizard that enables you to select a database connection or schema and generate related CMP entity beans that model the relationships among the tables of the database. The Related CMP Entity Bean wizard generates all the beans and relationships and groups them in an EJB module. The IDE provides editors that enable you to edit and add relationships. The IDE also displays custom, modal property sheets on which you can edit the properties of the beans and the EJB module, and it generates a deployment descriptor from your property settings.

New J2EE CMP Entity EJB Wizard Options. The J2EE CMP Entity EJB wizard has been updated to include two new options. On the first wizard panel, the section Source for Entities and Fields now contains the choices: CMP 2.x Bean Class and CMP 1.x Bean Class. This option allows a user to select the bean class for an existing EJB and the wizard will obtain the CMP field information from the class. Using these new options requires that the user understands several potential issues: 1.) This feature was not created as a robust feature with error checks for incorrect class files, 2) when generating a 2.x CMP EJB with additional finder and ejbSelect methods, the EJBQL will not be generated: you must manually add back all EJBQL statements since these statements are stored with the bean's deployment descriptor rather than in the class files, and 3) Although the Finish button is enabled, the user must continue through all the wizard screens and add the class files for all of the bean's classes (home, remote, localHome, local). If Finish is pressed before this last step is taken, the results will be inconsistent. An exception may appear or the EJB's finder and ejbSelect (for a 2.x bean) may not be generated as expected.

Is it best to use EJB-QL with an IDE rather than writing it out free-hand ?
regards
[ September 21, 2003: Message edited by: HS Thomas ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It depends on whether using the IDE improves your productivity. I haven't used an IDE with this kind of EJB-QL Wizard (if there was such a widget, I wasn't aware of it) so I can't retrospect on my own experiences.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Lasse.
This was an article on SUN ONE Forte !I'll see if I can find the link again.
regards
 
reply
    Bookmark Topic Watch Topic
  • New Topic