2016-08-02 15 views
1

私は実体「能力」を持っている春のデータJPAを使用してレコードを削除します。このエンティティは、二つの他のエンティティと<code>OneToMany</code>関係を持って、

@Secured("ROLE_ADMIN") 
    @RequestMapping(value="/competences/{id}",method= RequestMethod.DELETE) 
    public void deleteCompetence(@PathVariable Long id) { 
     competenceMetier.deleteCompetence(id); 
    } 

を次にdeleteCompetence機能は、次のようJpaRepository<Competence, Long>を拡張する能力リポジトリから削除関数を呼び出します:

そして、私は次のようCompetenceエンティティのIDを取ると残りはサービスを削除する必要があり

public void deleteCompetence(Long id) { 
     competenceRepository.delete(id); 
    } 

問題は、私は残りはメソッドを削除呼び出すとき、私はHTTPレスポンスとして200を得ることはありませんが、体内では何も、ログの同じ私はDELETE SQLクエリーを見ることができませんここでは、エンティティはまだデータベースに存在します。ここ

は私の実体である:

能力:

@Entity 
public class Competence implements Serializable { 
    @Id 
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
    private Long codeCompetence; 
    private String titre; 
    private Boolean activated = true; 

    @OneToMany(mappedBy="competence",cascade = CascadeType.ALL) 
    private Collection<CandidatCompetence> candidatCompetences; 

    @OneToMany(mappedBy="competence",cascade = CascadeType.ALL) 
    private Collection<OffreCompetence> offreCompetences; 

    @ManyToOne 
    @JoinColumn(name = "groupCompetence") 
    private GroupCompetence groupCompetence; 

    public Long getCodeCompetence() { 
     return codeCompetence; 
    } 

    public void setCodeCompetence(Long codeCompetence) { 
     this.codeCompetence = codeCompetence; 
    } 


    public String getTitre() { 
     return titre; 
    } 
    public void setTitre(String titre) { 
     this.titre = titre; 
    } 

    @JsonIgnore 
    @XmlTransient 
    public Collection<CandidatCompetence> getCandidatCompetences() { 
     return candidatCompetences; 
    } 

    @JsonSetter 
    public void setCandidatCompetences(Collection<CandidatCompetence> candidatCompetences) { 
     this.candidatCompetences = candidatCompetences; 
    } 

    @JsonIgnore 
    @XmlTransient 
    public Collection<OffreCompetence> getOffreCompetences() { 
     return offreCompetences; 
    } 

    public void setOffreCompetences(Collection<OffreCompetence> offreCompetences) { 
     this.offreCompetences = offreCompetences; 
    } 

    public Competence(String titre) { 
     super(); 
     this.titre = titre; 
    } 

    public Competence() { 
     super(); 
     // TODO Auto-generated constructor stub 
    } 

    @JsonIgnore 
    @XmlTransient 
    public GroupCompetence getGroupCompetence() { 
     return groupCompetence; 
    } 

    @JsonSetter 
    public void setGroupCompetence(GroupCompetence groupCompetence) { 
     this.groupCompetence = groupCompetence; 
    } 

    public Boolean getActivated() { 
     return activated; 
    } 

    public void setActivated(Boolean activated) { 
     this.activated = activated; 
    } 
} 

OffreCompetence:

@Entity 
public class OffreCompetence implements Serializable { 
    @Id 
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
    private Long codeOffreCompetence; 
    private String niveauRequis; 

    @ManyToOne 
    @JoinColumn(name = "competence") 
    private Competence competence; 

    @ManyToOne 
    @JoinColumn(name="offre") 
    private Offre offre; 


    public Long getCodeOffreCompetence() { 
     return codeOffreCompetence; 
    } 
    public void setCodeOffreCompetence(Long codeOffreCompetence) { 
     this.codeOffreCompetence = codeOffreCompetence; 
    } 
    public String getNiveauRequis() { 
     return niveauRequis; 
    } 
    public void setNiveauRequis(String niveauRequis) { 
     this.niveauRequis = niveauRequis; 
    } 

    public Competence getCompetence() { 
     return competence; 
    } 

    public void setCompetence(Competence competence) { 
     this.competence = competence; 
    } 
    @JsonIgnore 
    public Offre getOffre() { 
     return offre; 
    } 
    @JsonSetter 
    public void setOffre(Offre offre) { 
     this.offre = offre; 
    } 
    public OffreCompetence(String niveauRequis) { 
     super(); 
     this.niveauRequis = niveauRequis; 
    } 
    public OffreCompetence() { 
     super(); 
     // TODO Auto-generated constructor stub 
    } 


} 

CandidatCompetence:

@Entity 
public class CandidatCompetence implements Serializable { 
    @Id 
    @GeneratedValue(strategy=GenerationType.IDENTITY) 
    private Long codeCandidatCompetence; 
    private String niveauExperience; 
    @ManyToOne 
    @JoinColumn(name = "candidat") 
    private Candidat candidat; 
    @ManyToOne 
    @JoinColumn(name = "competence") 
    private Competence competence; 

    public Long getCodeCandidatCompetence() { 
     return codeCandidatCompetence; 
    } 
    public void setCodeCandidatCompetence(Long codeCandidatCompetence) { 
     this.codeCandidatCompetence = codeCandidatCompetence; 
    } 
    public String getNiveauExperience() { 
     return niveauExperience; 
    } 
    public void setNiveauExperience(String niveauExperience) { 
     this.niveauExperience = niveauExperience; 
    } 
    public Candidat getCandidat() { 
     return candidat; 
    } 
    public void setCandidat(Candidat candidat) { 
     this.candidat = candidat; 
    } 
    public Competence getCompetence() { 
     return competence; 
    } 
    public void setCompetence(Competence competence) { 
     this.competence = competence; 
    } 
    public CandidatCompetence(String niveauExperience) { 
     super(); 
     this.niveauExperience = niveauExperience; 
    } 
    public CandidatCompetence() { 
     super(); 
     // TODO Auto-generated constructor stub 
    } 


} 

GroupCompetence:

@Entity 
public class GroupCompetence implements Serializable { 

    @Id 
    @GeneratedValue(strategy= GenerationType.IDENTITY) 
    private Long codeGroupCompetence; 
    private String titre; 
    private Boolean activated = true; 

    @OneToMany(mappedBy="groupCompetence",cascade = CascadeType.ALL, fetch = FetchType.EAGER) 
    private Collection<Competence> competences; 

    public Long getCodeGroupCompetence() { 
     return codeGroupCompetence; 
    } 

    public void setCodeGroupCompetence(Long codeGroupCompetence) { 
     this.codeGroupCompetence = codeGroupCompetence; 
    } 

    public String getTitre() { 
     return titre; 
    } 

    public void setTitre(String titre) { 
     this.titre = titre; 
    } 

    public GroupCompetence(String titre) { 
     this.titre = titre; 
    } 

    public GroupCompetence() { 
    } 

    public Boolean getActivated() { 
     return activated; 
    } 

    public void setActivated(Boolean activated) { 
     this.activated = activated; 
    } 

    public Collection<Competence> getCompetences() { 
     return competences; 
    } 

    public void setCompetences(Collection<Competence> competences) { 
     this.competences = competences; 
    } 
} 

答えて

0

あなたは@TransactionalであなたのサービスメソッドdeleteCompetenceに注釈を付ける必要があります。

関連する問題