1 Reply Latest reply on Aug 8, 2003 2:24 PM by wgao

    findBy<PartOfCompositePK> doesn't work

    wgao Newbie

      Hi there,

      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:
      SELECT object(g)
      FROM employee g
      WHERE name=?1

      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.
      SELECT g.birthdate
      FROM employee AS g
      WHERE name=?1
      But I just don't understand why the first query doesn't work.

      Thanks.