Win a copy of Pipeline as Code this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

EJB-QL question

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Find all orders in which the shipping address differs from the billing address. This example assumes that the Bean Provider uses two distinct entity beans to designate shipping and billing addresses:

SELECT OBJECT(o)
FROM Order o
WHERE NOT
(o.shipping_address.state = o.billing_address.state AND
o.shipping_address.city = o.billing_address.city AND
o.shipping_address.street = o.billing_address.street)


If the Bean Provider uses a single entity bean in two different relationships for both the shipping address and the billing address, the above expression can be rewritten as:

SELECT OBJECT(o)
FROM Order o
WHERE o.shipping_address <> o.billing_address


My question:
Suppose I am using the 2nd version, how will the container do the comparsion, will it compare the primary keys?? or all the cmp-field??

Thanks.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The specs states that "EJB QL only permits like type values to be compared" with some exceptions. Also "Two entity objects of the same abstract schema type are equal if and only if they have the same primary key value."

So, in the above expression, both the addresses should be of the same entity type and if they are, then they will be compared by their primary keys.
 
It was the best of times. It was the worst of times. It was a tiny ad.
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic