Ok, guys. Now, after seeing the 'Matrix Reloaded' and having 3 pints, a can unveil my Zion-must-fall tricks
The correct answer is
E
==
These are not valid finder queries.
karthik, as they say 'had a flash-royal, but couldn't take the bank' (nothing personal

)
While half of the options are valid
EJB-QL queries, the question was about
finder queries. Again, the keyword is 'finder', and as we know, finders cannot return CMP fields (which emp.salary actually is).
if it were like karthik suggested:
SELECT emp
FROM Employee AS emp
WHERE emp.salary > ?1 AND emp.department = ?2
, this one would be a legal finder query. But the catch was about
select methods. They are allowed to return field values, unlike finder methods. But they can
only be called as internal methods of the bean and cannot be exposed in the interface (whatever).
I will step through the answers.
A: absolutely legal EJB-QL query, but applicable
only to 'select' methods. If you try to specify it as a finder definition, the container will.. well, say many bad things
B: No, the beauty of relationships in CMP 2.0 is you just specify logical entities, not physical database mappings, like departmentID.
C: While DISTINCT was introduced to confuse you, you have to remember that input parameters have a RHS (Right-Hand-Side) rule.
D: same as C + B.
The task was not to prove you wrong, but only to give you some insight on the experience I had with EJB-QL. It's more like knowing what you
can't do than
how to do it. Hope I'll have time to throw some more EJB-QL questions at you
