1 Reply Latest reply on Jul 13, 2009 6:00 AM by Wolfgang Knauf

    ManyToMany prob. with reading lists from entities

    Nicole Schweighardt Novice

      Hi,

      I have got two Entities. Appointment and AppointmentOffer.
      The relation is @ManyToMany.

      Appointment.java

      //bidirektional, inverse Seite
      @ManyToMany(fetch=FetchType.EAGER,mappedBy="appointments",cascade=CascadeType.MERGE)
      @IndexColumn(name="INDEX_COL")
      private List<AppointmentOffer> appointmentOffers= new ArrayList<AppointmentOffer>();


      AppointmentOffer.java
      //bidirektional, besitzende Seite
      @ManyToMany(fetch=FetchType.EAGER)
      @IndexColumn(name="INDEX_COL")
      private List<Appointment> appointments = new ArrayList<Appointment>();


      I have got two jsf-pages. One is first reading the appointmentOffers and then reading the list with appointments from this offers:

      show_appointment_offers.xhtml
      <rich:dataTable value="#{appointmentBeanInst.appointmentOffers}" var="appOffer">
      <rich:column>
       <h:outputText value="#{appOffer.id}" />
      </rich:column>
      ...
      <rich:column>
      <h:dataTable value="#{appOffer.appointments}" var="app">
      <h:column>
       <h:outputText value="#{app.title}" />
      </h:column>
      </rich:column>
      </rich:dataTable>


      The second pages tries to do the same with the appointments:
      show_appointments.xhtml
      <rich:dataTable value="#{appointmentBeanInst.freeAppointments}" var="appointment" >
      <rich:column sortBy="#{appointment.title}">
       <h:outputText value="#{appointment.title}" />
      </rich:column>
      ...
      <rich:column>
      <h:dataTable value="#{appointment.appointmentOffers}" var="appOffer">
      <h:column>
       <h:outputText value="#{appOffer.title}" />
      </h:column>
      </h:dataTable>
      ...
      

      The problem is that in the second page only one of the appointmentOffers is shown (in the list is only one appointmentOffer). I do not understand this. The only difference between the first and the second page is that appointmentOffer is the owner side. Is that the reason? How can I solve this?

      Thanks for your hints.
      NSchweig