No a hibernate member, but maybe cascade="all, delete-orphan" could do the
trick ?
________________________________
De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Ingo Villnow
Envoyé : mercredi 21 novembre 2007 11:05
À : hibernate-devel@lists.sourceforge.net
Objet : [Hibernate] problems with cascade
Hello,
i have the following problem. i have a table "projects" and a table "managers"
with a i think called "1:N" relationship.
My mapping file (partly):
<hibernate-mapping>
<class name="....Project" table="Project">
<set name="managers" inverse="true" cascade="all">
<key>
<column name="Projectid" not-null="true" />
</key>
<one-to-many class=".....Manager" />
</set>
</class>
</hibernate-mapping>
Now i want to delete all my managers concerning one special project and add the
new manager. So I do the following:
Manager manager;
ProjectDAO dao = new ProjectDAO();
Project project = (Project) dao.getSession().get(Project.class, projectID);
Set managers = project.getManagers();
managers.clear();
manager = new Manager();
manager.setEmployee(employee_manager);
manager.setFunction(managerFunction);
manager.setProject(project);
dao.getSession().save(manager);
managers.add(manager);
project.setManagers(managers);
dao.save(project);
But the thing is that only the new manager was added. The other database
entries were not deleted. I thought, if i update the parent entry (project) the
child entrys will be deleted automatically (project.getManagers.clear()). Where
is my problem? Can anybody help?
Thank you very much!!!
Greetings from Berlin!
Ingo
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
hibernate-devel mailing list
hibernate-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hibernate-devel