reset password
Author Message
afetiso
Posts: 84
Posted 17:09 Feb 12, 2015 |

    public Plan savePlan (Integer id, Plan plan )
    {            
        Department dep = entityManager.find( Department.class, id );
        List<Plan> newList = dep.getPlans();
        newList.add(plan);
        dep.setPlans(newList);
        return entityManager.merge( plan );
    }

where is mistake? It replace all plans connected to the department to the new one.

sikandarahmad
Posts: 19
Posted 17:12 Feb 12, 2015 |

Do like this.

 

 dep.getPlans().add(plan);

entityManager.merge(dep);

afetiso
Posts: 84
Posted 17:48 Feb 12, 2015 |

now doesn't help

it just change the name and data in database for plan related to this department and create a new relationship with plann and department