Hello;
I have two classes Partner and ProjectPartner : Partner___1:n______________1:1___ProjectPartner .
if I delete a ProjectPartner in collection Hibenate not delete the ProjectPartner in database but it is the foreign key of the table PROJECT_PARTNER a null.
Java:
Code:
public class Partner implements Serializable {
private String idPartner ;
private Collection<ProjectPartner > projectPartners ;
// getter and setter
}
public class ProjectPartner implements Serializable {
private Integer idProjectPartner ;
private Partner partner ;
// getter and setter
}
Mapping:
Code:
in ProjectPartner :
<many-to-one column="ID_PARTNER" name="partner" />
in Partner :
<set name="projectPartners" cascade="all-delete-orphan" inverse="false" >
<key column="ID_PARTNER" />
<one-to-many class="src.ProjectPartner" />
</set>
Service:
Code:
HashSet<ProjectPartner> _listprojects= new HashSet<ProjectPartner>(listProjects ); // listProjects = list used in JSF
//_listprojects contains two project
_listprojets.remove(Projetct1);
partner.setProjectPartners (_listprojets);
// DAO :partnerService
partnerService.save(partner);
Log Hibentae:
Code:
Hibernate: update PARTNER set GLOBAL_LOCATION_NUMBER=?, ID_PARTNER=?,............ where ID_PARTNER=?
Hibernate: update PROJECT_PARTNER set DESCRIPTION_PROJET_PARTENAIRE=?, ID_PARTNER=? ........where ID_PROJECT_PARTNER=?
[b]Hibernate: update PROJECT_PARTNER set CODE_PARTENAIRE=null where ID_PARTNER=?[/b]
Hibernate: update PROJECT_PARTNER set CODE_PARTENAIRE=? where ID_PROJECT_PARTNER=?
thank you in advance