title: updating rowediting datatable of primefaces and saving it in the database
body: <p>I'm using prime faces 3.4.2 and I'm trying to update an entity that contains a list of another object, using a row editing  datatable. My problem is that when I validate the change , the simple attributes of the entity are updated in the database , but the list is not. I don't know how to save the whole object in the data base. </p>
  
  <p>here you find the editing page :</p>
  
  <p>`<br>
                </p>
  
  <pre><code>&lt;p:panel style="width:1000px;  ;font: lighter 70.5% Arial, Helvetica, sans-serif ; " header="Informations Générales"&gt;
          &lt;p:growl id="growl" showDetail="true" sticky="true" style="font-size: small;"  /&gt;  
              &lt;h:panelGrid columns="2" cellpadding="5"&gt;
                  &lt;h:outputLabel value="Société" /&gt;
                  &lt;p:inputText id="custSoc" value="#{CustomerCtrl.selectedCust.company}"/&gt;
  
                  &lt;h:outputLabel value="Secteur d'activité" /&gt;
                  &lt;p:inputText id="custActivite" value="#{CustomerCtrl.selectedCust.secteurActivite}"  /&gt;
  
                  &lt;h:outputLabel value="Nom du propriétaire" /&gt;
                  &lt;p:inputText id="custprop" value="#{CustomerCtrl.selectedCust.proprietaire}"  /&gt;
             &lt;/h:panelGrid&gt;
  
          &lt;p:tabView id="tabView"&gt;    
              &lt;p:tab title="Coordonnées"&gt;
  
  &lt;p:growl id="messages" showDetail="true"/&gt;  
  
  &lt;p:dataTable var="cu" value="#{CustomerCtrl.selectedCust.coordonnee}" id="carList" editable="true"&gt;  
  
      &lt;f:facet name="header"&gt;  
         Coordonnées  
      &lt;/f:facet&gt;  
  
          &lt;p:columnGroup type="header"&gt;  
          &lt;p:row&gt;  
              &lt;p:column colspan="5" headerText="Adresses"  /&gt;                    
              &lt;p:column colspan="5" headerText="Contacts" /&gt;  
  
          &lt;/p:row&gt;  
  
          &lt;p:row&gt;  
              &lt;p:column headerText="Num" style="width:2cm"/&gt;  
              &lt;p:column headerText="Rue/Avenue" style="width:3cm"/&gt;  
              &lt;p:column headerText="Code postal" style="width:2cm" /&gt;                   
              &lt;p:column headerText="Ville" style="width:2.5cm" /&gt; 
              &lt;p:column headerText="Pays" style="width:2.5cm" /&gt;
              &lt;p:column headerText="Fixe" style="width:2cm"/&gt;
              &lt;p:column headerText="Mobile" style="width:2cm"/&gt;
              &lt;p:column headerText="Fax" style="width:2cm"/&gt;
              &lt;p:column headerText="E-mail" style="width:3.7cm"/&gt;
              &lt;p:column headerText=" " /&gt;
  
          &lt;/p:row&gt;
          &lt;/p:columnGroup&gt;
  
      &lt;p:ajax event="rowEdit" listener="#{CustomerCtrl.onEdit}" update=":form:messages" /&gt;  
      &lt;p:ajax event="rowEditCancel" listener="#{CustomerCtrl.onCancel}" update=":form:messages" /&gt;  
  
      &lt;p:column headerText="Num"&gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.number}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;p:inputText value="#{cu.number}" style="width:90%"/&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt; 
  
      &lt;p:column headerText="Rue/Avenue"&gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.street}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;p:inputText value="#{cu.street}" style="width:90%"/&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt;  
  
      &lt;p:column headerText="Code postal"&gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.zipcode}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;p:inputText value="#{cu.zipcode}" style="width:90%"/&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt; 
  
       &lt;p:column headerText="Ville"&gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.city.text}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;h:selectOneMenu value="#{cu.city.text}" style="width:100%"&gt;  
                      &lt;f:selectItems value="#{CustomerCtrl.cityList}" style="width:100%" 
                          var="city"   
                          itemLabel="#{city}"  
                          itemValue="#{city}" /&gt;  
                  &lt;/h:selectOneMenu&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt;  
  
       &lt;p:column headerText="Pays" &gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.country.text}" style="width:100%" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;h:selectOneMenu value="#{cu.country.text}" style="width:100%"&gt;  
                      &lt;f:selectItems value="#{CustomerCtrl.countryList}"  style="width:100%"
                          var="color"   
                          itemLabel="#{color}"  
                          itemValue="#{color}" /&gt;  
                  &lt;/h:selectOneMenu&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt; 
  
      &lt;p:column headerText="Fixe"&gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.phone}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;p:inputText value="#{cu.phone}" style="width:90%"/&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt;
  
      &lt;p:column headerText="Mobile" &gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.mobile}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;p:inputText value="#{cu.mobile}" style="width:90%"/&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt;
  
      &lt;p:column headerText="Fax" &gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.fax}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;p:inputText value="#{cu.fax}" style="width:90%"/&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt;
  
      &lt;p:column headerText="E-mail" &gt;  
          &lt;p:cellEditor&gt;  
              &lt;f:facet name="output"&gt;  
                  &lt;h:outputText value="#{cu.email}" /&gt;  
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;  
                  &lt;p:inputText value="#{cu.email}" style="width:90%"/&gt;  
              &lt;/f:facet&gt;  
          &lt;/p:cellEditor&gt;  
      &lt;/p:column&gt;
  
      &lt;p:column style="width:6%"&gt;  
          &lt;p:rowEditor /&gt;  
      &lt;/p:column&gt;  
  
  &lt;/p:dataTable&gt;
  
  
             &lt;/p:tab&gt;
             &lt;p:tab title="Compte"&gt;
                  &lt;h:panelGrid columns="2" cellpadding="5"&gt;
                  &lt;h:outputLabel value="Login"  /&gt;
                  &lt;p:inputText id="userLogin" value="#{CustomerCtrl.selectedCust.login}"  /&gt;
  
                  &lt;h:outputLabel value="Mot de passe"  /&gt;
                  &lt;p:password id="userpass" value="#{CustomerCtrl.selectedCust.password}"  /&gt;
                  &lt;/h:panelGrid&gt;
              &lt;/p:tab&gt;
                &lt;p:tab title="Applications"&gt;
                  &lt;h:panelGrid columns="2" cellpadding="5"&gt;
  
  
                  &lt;/h:panelGrid&gt;
              &lt;/p:tab&gt;
                &lt;p:tab title="Interventions"&gt;
                  &lt;h:panelGrid columns="2" cellpadding="5"&gt;   
                  &lt;/h:panelGrid&gt;
              &lt;/p:tab&gt;
  
              &lt;/p:tabView&gt;    
  </code></pre>
  
     
  
   
            
  
  <pre><code>        &lt;/p:panel&gt;
        &lt;br/&gt;
  </code></pre>
  
  <p>`</p>
  
  <p>and here is my managedbean :`@ManagedBean(name = "CustomerCtrl")
  @ViewScoped
  public class CustomerController implements Serializable {</p>
  
  <pre><code>/**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  private int idSelected;
  
  private Customer selectedCust ;
  
  private Coordonnee selectedCoord = new Coordonnee();
  
  private Coordonnee filteredCoord = new Coordonnee();
  
  private List&lt;Customer&gt; filteredCusts;
  
  private int cityId;
  
  private int countryId;
  
  private List&lt;SelectItem&gt; cityList = new ArrayList&lt;SelectItem&gt;();
  
  private List&lt;SelectItem&gt; countryList = new ArrayList&lt;SelectItem&gt;();
  
  private List&lt;Customer&gt; custmrs = new ArrayList&lt;Customer&gt;();
  
  private List&lt;Coordonnee&gt; coordonnees = new ArrayList&lt;Coordonnee&gt;();
  
  private Coordonnee selectedCustomerCoordonne;
  
  @EJB
  private SettingsBean settingBean;
  
  public CustomerController() {
      if (selectedCust != null) {
          coordonnees = (List&lt;Coordonnee&gt;) settingBean.FindCoordonneeByCustomer(selectedCust.getId());
      }
  }
  
  public void createCustomer() {
      System.out.println("hello createCustomer");
      System.out.println("selectedcust :"+selectedCust.getCompany());
      System.out.println("selectedcustCoordonnee 1 :"+selectedCustomerCoordonne);
      if(selectedCust==null){
          System.out.println("entré");
          selectedCust= new Customer();
          System.out.println("nouvelle instance créé");
          settingBean.createCustomer(selectedCust);
          settingBean.createCoordonnee(selectedCustomerCoordonne);
          System.out.println("Nouveau client " + selectedCust.getCompany() + " ajoutée");
      }
      else{
          System.out.println("editer");
          selectedCust.setCoordonnee(coordonnees);
          settingBean.editCustomer(selectedCust);
          System.out.println("client " + selectedCust.getCompany() + " édité");   
      }
  }
  
  public List&lt;Customer&gt; getCustmrs() {
      custmrs = settingBean.findAllCustomers();
      return custmrs;
  }
  
  public void setCustmrs(List&lt;Customer&gt; custmrs) {
      this.custmrs = custmrs;
  }
  
  public void preRenderView() {
      HttpSession session = (HttpSession) FacesContext.getCurrentInstance()
              .getExternalContext().getSession(true);
  }
  
  public Customer getSelectedCust() {
      if (selectedCust == null) {
          selectedCust = (Customer) FacesContext.getCurrentInstance()
                  .getExternalContext().getSessionMap().get("selectedCust");
          System.out.println("Par session");
          if (selectedCust == null) {
              selectedCust = new Customer();
              selectedCust.setCoordonnee(new ArrayList&lt;Coordonnee&gt;());
          } else
          selectedCust.setCoordonnee(settingBean
                  .FindCoordonneeByCustomer(selectedCust.getId()));
  
      }
      return selectedCust;
  }
  
  public void setSelectedCust(Customer selectedCust) {
      this.selectedCust = selectedCust;
  }
  
  public List&lt;Customer&gt; getFilteredCusts() {
      return filteredCusts;
  }
  
  public void setFilteredCusts(List&lt;Customer&gt; filteredCusts) {
      this.filteredCusts = filteredCusts;
  }
  
  public List&lt;Coordonnee&gt; getCoordonnees() {
      if (selectedCust != null) {
          coordonnees = (List&lt;Coordonnee&gt;) settingBean.FindCoordonneeByCustomer(selectedCust.getId());
      }
      return coordonnees;
  }
  
  public void setCoordonnees(List&lt;Coordonnee&gt; coordonnees) {
      this.coordonnees = coordonnees;
  }
  
  public void setCustomerToEdit(Customer customerToEdit) {
  }
  
  public String removeCustomer() {
      if (selectedCust != null) {
          System.out.println("in delete");
          String selected = selectedCust.getCompany();
          System.out.println("supprimer " + selected + "");
          custmrs.remove(selectedCust);
          settingBean.removeCustomer(selectedCust);
          System.out.println("client supprimé");
      }
      return "";
  }
  
  
      public String removeCustomercoordonnee() {
      if (selectedCustomerCoordonne != null) {
          System.out.println("coordonne in delete");
          String selected = selectedCustomerCoordonne.getEmail();
          System.out.println("supprimer " + selected + "");
          settingBean.removeCustomerCoordonnee(selectedCustomerCoordonne);
          System.out.println("coordonne supprimé");
      }
      return "";
  }
  
  public String editCustomer() {
      if (selectedCust != null) {
          FacesContext.getCurrentInstance().getExternalContext()
                  .getSessionMap().put("selectedCust", selectedCust);
          System.out.println("selected "
                  + FacesContext.getCurrentInstance().getExternalContext()
                          .getSessionMap().get("selectedCust"));
      }
      return "customeradd.xhtml?faces-redirect=true";
  
  }
  
  public int getCityId() {
      return cityId;
  }
  
  public void setCityId(int cityId) {
      this.cityId = cityId;
  }
  
  public int getCountryId() {
      return countryId;
  }
  
  public void setCountryId(int countryId) {
      this.countryId = countryId;
  }
  
  public List&lt;SelectItem&gt; getCityList() {
      cityList = new ArrayList&lt;SelectItem&gt;();
      List&lt;City&gt; Listcity = settingBean.findAllCity();
      for (City c : Listcity) {
          cityList.add(new SelectItem(c.getId(), c.getText()));
      }
      return cityList;
  }
  
  public void setCityList(List&lt;SelectItem&gt; cityList) {
      this.cityList = cityList;
  }
  
  public List&lt;SelectItem&gt; getCountryList() {
      cityList = new ArrayList&lt;SelectItem&gt;();
      List&lt;Country&gt; Listcountry = settingBean.findAllCountry();
      for (Country c : Listcountry) {
          countryList.add(new SelectItem(c.getId(), c.getText()));
      }
      return countryList;
  }
  
  public void setCountryList(List&lt;SelectItem&gt; countryList) {
      this.countryList = countryList;
  }
  
  public int getIdSelected() {
      return idSelected;
  }
  
  public void setIdSelected(int idSelected) {
      this.idSelected = idSelected;
  }
  
  public Coordonnee getSelectedCustomerCoordonne() {
  
      return selectedCustomerCoordonne;
  }
  
  public void setSelectedCustomerCoordonne(
          Coordonnee selectedCustomerCoordonne) {
      this.selectedCustomerCoordonne = selectedCustomerCoordonne;
  }
  
  public Coordonnee getSelectedCoord() {
      return selectedCoord;
  }
  
  public void setSelectedCoord(Coordonnee selectedCoord) {
      this.selectedCoord = selectedCoord;
  }
  
  public Coordonnee getFilteredCoord() {
      return filteredCoord;
  }
  
  public void setFilteredCoord(Coordonnee filteredCoord) {
      this.filteredCoord = filteredCoord;
  }
  
  public void onEdit(RowEditEvent event) {  
      FacesMessage msg = new FacesMessage("Cliquer sur enregistrer pour valider la modification", ((Coordonnee) event.getObject()).getCustomer().getCompany());  
  
      FacesContext.getCurrentInstance().addMessage(null, msg);  
  }  
  
  public void onCancel(RowEditEvent event) {  
      FacesMessage msg = new FacesMessage("Modification annulée", ((Coordonnee) event.getObject()).getCustomer().getCompany());  
  
      FacesContext.getCurrentInstance().addMessage(null, msg);  
  }  
  </code></pre>
  
  <p>}`</p>
  
  <p>Pleaaase help me to save the both objects.</p>