When I looked at some old topics, I found this question which I don't know the answer, anybody have a clue? "EJB-QL: You should know that what variables should be part of both PrimaryKey class as well as the cmp bean?"
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
Sudhir V<br />(SCJP 1.2, SCWCD, OCA, SCBCD)
Joined: Mar 18, 2002
Thanks, Sudhir. The problem is I don't really understand the question too. I found the original topic, http://www.coderanch.com/t/157746/java-EJB-SCBCD/certification/important-tips-before-taking-exam It is one of the tips in "few important tips before taking exam ", that's why I'm so concern about this question. EJB-QL: 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
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 /Regards Magnus