title: Attempting to save transient entity from dropdown list jsp hibernate
body: <p>Trying to save child entity containing 2 existing parents in the DB ( user and type , the user works fine) , i don't know why it tells me the type is transient while i got it ( populated the dropdown list) from the DB i get : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>WARN  UnresolvedEntityInsertActions - HHH000437: Attempting to save one or more entities that have a non-nullable association with an unsaved transient entity. The unsaved transient entity must be saved in an operation prior to saving these dependent entities.
   Unsaved transient entity: ([jpa.project.model.DemTypeDemande#0])
   Dependent entities: ([[jpa.project.model.DemDemande#8950]])
   Non-nullable association(s): ([jpa.project.model.DemDemande.demTypeDemande])</code></pre>
  </div>
  </div>
  </p>
  
  <p>Controller : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> @RequestMapping(value = "/demandes/manage",method = RequestMethod.GET)
   public ModelAndView manageUsers(HttpServletRequest request) throws IOException {
    ModelAndView model = new ModelAndView();           
   //----1.ADD USER
       model.addObject("demUser", new DemUser()); 
   //----2.ADD TYPES
    List&lt;DemTypeDemande&gt; listTypes = service.getTypeDemandes();
    model.addObject("listTypes", listTypes);    
   //----3.ADD DEMANDE
        DemDemande demande = new DemDemande();
     model.addObject("DemDemande", demande); 
   
   model.setViewName("managedemandes");
    return model; }
    
   @RequestMapping(value = "/demandes/actionadddemande", method = RequestMethod.POST)
   public String actionadduser(HttpServletRequest request ,@ModelAttribute("demTypeDemande") DemTypeDemande typeDemande,@ModelAttribute ("DemDemande") DemDemande demande , BindingResult result) {
    demande.setDemUser(service.getUserByUsername(service.getConnectedUsername(request)));
    demande.setDemTypeDemande(typeDemande);
          service.addDemande(demande);
   return "redirect:/demandes/manage";
   }</code></pre>
  </div>
  </div>
  </p>
  
  <p>JSP : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>        &lt;form:form action="actionadddemande" method="POST" commandName="DemDemande"&gt;
          &lt;table&gt;
                      &lt;form:hidden path="idDemande" /&gt;
                       &lt;form:hidden path="demUser"  /&gt;          
          &lt;tr&gt;
      &lt;td&gt;Types :&lt;/td&gt;
      &lt;td&gt;
    &lt;form:select path="demTypeDemande"&gt;
           &lt;form:options items="${listTypes}"  itemValue="idTypeDemande" itemLabel="libTypeDemande"&gt;&lt;/form:options&gt;
      &lt;/form:select&gt;&lt;/td&gt;
  &lt;/tr&gt;
              &lt;tr&gt;
                  &lt;td colspan="2" align="center"&gt;&lt;input type="submit" value="Save"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;/form:form&gt;</code></pre>
  </div>
  </div>
  
  Type entity relation : </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code> //bi-directional many-to-one association to DemDemande
   @OneToMany(mappedBy="demTypeDemande")
   private List&lt;DemDemande&gt; demDemandes;</code></pre>
  </div>
  </div>
  
  Demande entity relation :
  <div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code> //bi-directional many-to-one association to DemTypeDemande
  @ManyToOne(optional = false)
   @JoinColumn(name="ID_TYPE_DEMANDE")
   private DemTypeDemande demTypeDemande;</code></pre>
  </div>
  </div>
  </p>