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.
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%'
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad: