This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes EJB-QL Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "EJB-QL Question" Watch "EJB-QL Question" New topic

EJB-QL Question

Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
If we had a "Boss" EJB with a single CMR field named "employee", and an Employee EJB using a "Pay" class as its pay CMP field, are both of these allowable:

SELECT b.employee FROM Boss b

[ May 15, 2004: Message edited by: Dale Seng ]
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
Here's a second question, if you please...

Say we have a one to many relationship: House 1 ---- * Room (a house is made of of several rooms, one room may belong to only one house), and House has a collection-valued relation field whose value is 'room'.

Our database looks like this:

Can we do this:

FROM House h, IN( r
WHERE r = 'Kitchen'

[ May 15, 2004: Message edited by: Dale Seng ]
Shahfazal Mohammed
Ranch Hand

Joined: Jan 08, 2004
Posts: 41

I guess when you say a 1--* relationship, it's more better represented when the entities are different tables - House table and Room table (you know, normalization and stuff)
and, technically, when you say a collection-valued relation field - 'room', it's a getter method getRoom() (or more comfortably getRooms() when your cmr-field is 'rooms') which will return a Collection of local component interfaces of the Room entity bean (a different table), so that you can iterate thru them. your database might actually have to be modified as

in this case your EJB-QL would look something like -

hope this helps

I agree. Here's the link:
subject: EJB-QL Question
It's not a secret anymore!