Did you try to set cascade to the value I mentioned in my previous post ? The
project entry should not be deleted, if that's what you meant.
________________________________
De : Ingo Villnow [mailto:[EMAIL PROTECTED]
Envoyé : mercredi 21 novembre 2007 11:20
À : Massip, Etienne
Objet : Re: [Hibernate] problems with cascade
If I delete the entry in the project-table than the childs will be deleted,
to.. that's all fine. But i only want to delete the children, without deleting
the parent entry, for example "project.getManagers().clear() - The problem is
that it would be hard to find all manager-elements by projectid and to delete
them one by another. Is there an easier way?
thanks
2007/11/21, Massip, Etienne <[EMAIL PROTECTED]>:
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
--
Liebe Grüße
Ingo
sites:
http://www.herrgustav.de
http://www.myspace.com/herrgustav
http://www.myspace.com/mrvill
mailto:
[EMAIL PROTECTED] - [EMAIL PROTECTED] - [EMAIL PROTECTED]
-------------------------------------------------------------------------
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