1 Reply Latest reply on Feb 21, 2006 6:41 PM by Emmanuel Bernard

    Adding entity in a ManyToMany relation

    Frédéric EECKHOUT Newbie


      I have a ManyToMany relation with Entreprise and Tool :
      #Entreprise side

      public Collection<Tool> getTools() {
       return tools;

      # Tool side
      public Collection<Entreprise> getEntreprises() {
       return entreprises;

      The table (Tool_Entreprise) is well created in MySQL.

      But I can't add any tool in the entreprise doing (entreprise and tool being initialized) :
      entreprise.getTools().add( tool );

      No any record is inserted in the table.
      (And no error in jboss/hibernate logs)

      When I Insert a record manually in the table with the right ids, I can see the result doing entreprise.getTools(); (It works).

      How can I add a tool to an entreprise in Java ??