From: Massip, E. <Eti...@sa...> - 2007-11-21 10:13:13
|
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 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=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> 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 =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); 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 |