I have a table called employee and the PK is "name" and "birthdate". I wrote my own PK class. I have a find method -- findByName(String name), with EJB-QL like this:
FROM employee g
After I got the enumeration, I try to iterate and print out birthdate of each record and other columns. However, I got "NullPointerException" from "equal()" method in my PK class when I try to call getBirthDate(). It seems that birthdate field hasn't been populated, it is still null, and since it is part of PK, I got the exception.
Does anyone have the same problem? The same code I have works fine for a Bean with atomic PK field. Should the code be different for a find method that takes part of composite PK as its parameter?
I also tried to modify my EJB-QL, and this one works fine to retrieve birthdate.
FROM employee AS g
But I just don't understand why the first query doesn't work.
Oh, "name" is a FK from another table. So the parameter to my find Method is a FK, and this FK is part of the composite PK.
I got NullPointerException from hashCode() and equal() methods in my PK class.