From: Massip, E. <Eti...@sa...> - 2007-11-21 10:25:31
|
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:ing...@go...]=20 Envoy=E9 : mercredi 21 novembre 2007 11:20 =C0 : 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?=20 thanks 2007/11/21, Massip, Etienne <Eti...@sa...>:=20 No a hibernate member, but maybe cascade=3D"all, delete-orphan" could = do the trick ? ________________________________ De : hib...@li... = [mailto:hib...@li...] De la part de = Ingo Villnow Envoy=E9 : mercredi 21 novembre 2007 11:05 =C0 : hib...@li... Objet : [Hibernate] problems with cascade =09 =09 =09 Hello, =09 i have the following problem. i have a table "projects" and a table = "managers" with a i think called "1:N" relationship. =09 My mapping file (partly): =09 <hibernate-mapping> <class name=3D"....Project" table=3D"Project"> <set name=3D"managers" inverse=3D"true" cascade=3D"all"> <key> <column name=3D"Projectid" not-null=3D"true" /> </key> <one-to-many class=3D".....Manager" /> </set> </class> </hibernate-mapping> =09 Now i want to delete all my managers concerning one special project and = add the new manager. So I do the following: =09 Manager manager; ProjectDAO dao =3D new ProjectDAO(); Project project =3D (Project) dao.getSession().get(Project.class, = projectID); Set managers =3D project.getManagers(); managers.clear(); manager =3D 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); =09 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? =09 Thank you very much!!! =09 Greetings from Berlin! =09 Ingo =09 = -------------------------------------------------------------------------= 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 hib...@li... https://lists.sourceforge.net/lists/listinfo/hibernate-devel=20 =09 =09 --=20 Liebe Gr=FC=DFe Ingo sites: http://www.herrgustav.de http://www.myspace.com/herrgustav=20 http://www.myspace.com/mrvill =20 mailto: Ing...@we... - Mr...@we... - Vil...@gm...=20 |