0 Replies Latest reply on May 11, 2006 5:42 AM by chrismalan

    Access members of composite PK with EJBQL

    chrismalan

      I have two classes with composite PKs. The PK classes are annotated with @Embeddable and the IDs with @EmbeddedId.

      One class (table) has a composite key made up of a student primary key and a test primary key. The class is called something very original, like Student_Test. The PK is called ID. The sudent PK is a code, say his dob concatenated with his initials (if there are two identical ones, concat 2 to the second one).

      If I want to get all instances of Sudent_Test for a particular student, do I do this?

      Query q = manager.createQuery("select st from Student_Test st where st.ID.student = :student")
      

      Searches through the forums have led me to believe it is not going to be this easy, but have not provided clear answers. There is some sugestion that Student should be a member of Student_Test. But with a composite PK already holding enough to get a reference to Student, that seems wasteful.

      Any ideas?