Win a copy of OCP Oracle Certified Professional Java SE 11 Developer Practice Tests this week in the OCP 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Ron McLeod
  • Tim Cooke
Sheriffs:
  • Devaka Cooray
  • paul wheaton
  • Mark Herschberg
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
  • Jj Roberts
Bartenders:
  • Carey Brown
  • salvin francis
  • Piet Souris

Entity bean representing a query

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

I guess Entity bean just don't represents a single table in database, it could represent a query which is join of multiple tables. In the case of multiple tables, it is possible to use CMP? I guess it can be done using Relationships, but that will result in one entity bean representing one table and then having relationship between them in a DD.
Has anybody done this type of Entity bean (in CMP or BMP style) and what did they do?


Well the reason I am asking this question is because I don't think CMP will be of much use if it could only represent one table at a time.

Regards
Mini
 
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mini mehta:
...I don't think CMP will be of much use if it could only represent one table at a time.



I think if you make an EJBQL that goes like this:

SELECT Object(o)
FROM Orders o, IN(o.lineItems) i
WHERE i.description LIKE '%computer%'

There has to be a join going on. In fact, I think if you check the xml files that get built by your deployment tool, you will see SQL that affects this join.

--Dale--
 
mini mehta
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Dale Seng:


I think if you make an EJBQL that goes like this:

SELECT Object(o)
FROM Orders o, IN(o.lineItems) i
WHERE i.description LIKE '%computer%'

There has to be a join going on. In fact, I think if you check the xml files that get built by your deployment tool, you will see SQL that affects this join.

--Dale--



But it is not joining other tables.

Mini
 
Dale Seng
Ranch Hand
Posts: 275
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In EJB-QL I think you get join behaviour without the JOIN keyword. The example above returns 'rows' from the order table, based on data in the items table. So there must be a foriegn key in the items table that is being used to 'join' with the orders table.

Here's a 'real' example...

I put this in my DD:



And then I deploy my bean, and it works.

Then I go and poke around and find sun-j2ee-ri.xml and see this:



I don't know if I really know exactly how to read that, but there's a lot going on there whenever I use the "IN" keyword!

You can 'join' in regular sql without the keyword join:
select *
from orders o, items i
where o.orderNumber = i.orderNumber
and i.desc like '%computer%'

--Dale--
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic