File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes question about EJB-QL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "question about EJB-QL" Watch "question about EJB-QL" New topic

question about EJB-QL

calvin zhu
Ranch Hand

Joined: Mar 18, 2002
Posts: 54
When I looked at some old topics, I found this question which I don't know the answer, anybody have a clue?
You should know that what variables should be part of both PrimaryKey class as well as the cmp bean?"

SCEA, SCJD, SCWCD, SCBCD, SCJP<br />IBM WebSphere Portal certification
Sudhir V
Ranch Hand

Joined: Dec 25, 2002
Posts: 143
Let me make sure I understood the question correctly: You are asking does one have to know the primary key fields and CMP fields before writing EJB-QL queries?
I don't think one needs to know the fields which compose the primary key. However one shud know the virtual i.e. CMP fields coz the only way for the bean to interact with the database is thru the abstract getters and setters methods. So you are allowed to use only the CMP fields in EJB-QL query.
HFE Pg 401 says: "As a bean provider, you can happily write all the queries you want, trusting that the Deployer will in the end, map your CMP fields to the real tables and data".
Also example in HFE Pg 403 says: "genre" must be CMP field in the Movie Bean, which means you can find a getter/setter method for it in the bean class" (as I told before).

Sudhir V<br />(SCJP 1.2, SCWCD, OCA, SCBCD)
calvin zhu
Ranch Hand

Joined: Mar 18, 2002
Posts: 54
Thanks, Sudhir. The problem is I don't really understand the question too.
I found the original topic,
It is one of the tips in "few important tips before taking exam ", that's why I'm so concern about this question.
You should know how to write a query
You should know whats illegal in EJB-QL query
You should know about WHERE , FROM , IN ,AS clauses
You should know about Pathexpressions
You should know about collections
You should know that ejbSelect<Methods>are written in bean class not in home interface
You should know that ejbFind<Methods> are written in home interface
You should know the difference between find and select method
You should be aware of PrimaryKey field, class , type
You should be aware of defining custom composite primary key class and the things it need to contain
You should know that what variables should be part of both PrimaryKey class as well as the cmp bean?
You should know about EJB-QL and Abstract Presistance Schema
Magnus Stattin
Ranch Hand

Joined: Jun 05, 2003
Posts: 65
My guess is that it means that the fields in the primary key class have to be a subset of the cmp fields declared for the bean.
Here are the other rules for the primary key class:
1) it has to be declared public
2) it should have a no arg constructor
3) the fields have to be public
I agree. Here's the link:
subject: question about EJB-QL
jQuery in Action, 3rd edition