1 Reply Latest reply on Feb 9, 2004 2:36 PM by sesques

    [newbie] EJB-QL

    jasonvanbrackel

      Here's my situation I have three tables

      PARENT
      parentid pk
      contactid fk
      addressid fk
      username unique
      password

      STUDENT
      studentid pk
      etc...

      PARENT_STUDENT - (Join Table)
      studentid pk fk
      parentid pk fk

      I have created basic cmp beans for all three tables. I was wondering how I could possibly phrase an finder query to get the students from the parents based on the parent_student mapping. Do I have to findByUsername on the ParentBean on login then findByParentID on the ParentStudentBean the do a findByStudentID for each result in the findByParentID query? or can I use some kind of join like in SQL?

      Any help would be appreciated.

      Jason

        • 1. Re: [newbie] EJB-QL
          sesques

          Hi,

          My opinion is that you should use relations (cmr fields).
          PARENT_STUDENT is just a relation table.

          Then giving a parent, you can get all the students and vice versa with a single query (find a parent or find a student).

          Hope this helps you.