-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Problem in mapping collection :
PostPosted: Mon Oct 08, 2012 3:23 am 
Newbie

Joined: Thu Oct 04, 2012 8:10 am
Posts: 4
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.