4 Replies Latest reply on Oct 6, 2006 12:07 PM by pmuir

    Multiple POJO Custom JSF DataTable

    johnurban

      Seam Design Question:

      I need to create a jsf datatable view with data from 3 different tables. My sql would look something like this:

      select t1.firstname, t1.lastname, t2.roomName, t3.secureCode
      from person t1, room t2, attendance t3
      where t1.roomId = t2.roomId
      and t1.personId = t3.personId

      My question:

      Is the best approach to create an Attendance entity(POJO) with firstname, lastname, roomname and securecode. Then create SFSB that executes the above SQL storing the data in a List of Attendance objects tying it back to the JSF?

        • 1. Re: Multiple POJO Custom JSF DataTable
          pmuir

          I would suggest designing your entity model first then designing the view. Remember you can traverse entity relationships in EL using e.g. #{attendance.person.firstname} and that EJB3 does lazy fetching so there is no need to explicity fetch the entire object graph in the query.

          • 2. Re: Multiple POJO Custom JSF DataTable
            johnurban

            You are really answering my question in the latter post, but I am curious about what you mean by:


            Remember you can traverse entity relationships in EL


            Pardon my ignorance. I am EJB30/Seam acronym challenged at the moment. I'm digesting alot in a short period of time here.

            • 3. Re: Multiple POJO Custom JSF DataTable
              pmuir

              Very simple.

              public class Person {
              
              
              House house;
              
              // more fields, getters and setters for house
              }
              
              public class CD {
              
              String number;
              String road;
              
              // etc.
              }
              
              #{person.house.road}


              If Person had been outjected. More generally you can traverse associations on an object graph.

              • 4. Re: Multiple POJO Custom JSF DataTable
                pmuir

                Sorry, the second class should be called House!