SALUT tous le monde.

En fait je suis entrain de réaliser une application en Spring+jsf+hibernate.
j'ai fait ma couche model et DAO et je suis en train de faire des tests.
lorsque j'ai voulu tester une methode qui supprime un objet a ma grande surprise rien ne se passe et j'ai pas d'erreur.

Voila mon Bean

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
 
package com.project.model;
 
// Generated 28 juil. 2012 15:18:00 by Hibernate Tools 3.4.0.CR1
 
import java.util.ArrayList;
import java.util.Collection;
 
 
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
 
/**
 * Categorie generated by hbm2java
 */
@Entity
@Table(name = "Categorie", schema = "dbo", catalog = "ECommerce")
public class Categorie implements java.io.Serializable {
 
	/**
         * 
         */
	private static final long serialVersionUID = 1L;
	private int idCategorie;
	private Categorie categorie;
	private String intitule;
	private String affiche;
	private String image;
	private String description;
	private Collection<Produit> produits = new ArrayList<Produit>();
	private Collection<Categorie> categories = new ArrayList<Categorie>();
 
	public Categorie() {
	}
 
	public Categorie(int idCategorie, Categorie categorie, String intitule,
	    String affiche, String description) {
		this.idCategorie = idCategorie;
		this.categorie = categorie;
		this.intitule = intitule;
		this.affiche = affiche;
		this.description = description;
	}
 
	public Categorie(int idCategorie, Categorie categorie, String intitule,
			String affiche, String description, Collection<Produit> produits,
			Collection<Categorie> categories) {
		this.idCategorie = idCategorie;
		this.categorie = categorie;
		this.intitule = intitule;
		this.affiche = affiche;
		this.description = description;
		this.produits = produits;
		this.categories = categories;
	}
 
	@Id
	@Column(name = "idCategorie", unique = true, nullable = false)
	@GeneratedValue(strategy=GenerationType.AUTO)
	public int getIdCategorie() {
		return this.idCategorie;
	}
 
	public void setIdCategorie(int idCategorie) {
		this.idCategorie = idCategorie;
	}
 
	@ManyToOne(fetch = FetchType.LAZY,cascade=CascadeType.PERSIST)
	@JoinColumn(name = "Categorie_Parent")
	public Categorie getCategorie() {
		return this.categorie;
	}
 
	public void setCategorie(Categorie categorie) {
		this.categorie = categorie;
	}
 
	@Column(name = "Intitule", nullable = false, length = 30)
	public String getIntitule() {
		return this.intitule;
	}
 
	public void setIntitule(String intitule) {
		this.intitule = intitule;
	}
 
	@Column(name = "Affiche", nullable = false)
	public String getAffiche() {
		return this.affiche;
	}
 
	public void setAffiche(String affiche) {
		this.affiche = affiche;
	}
    @Lob
	@Column(name = "Description")
	public String getDescription() {
		return this.description;
	}
 
	public void setDescription(String description) {
		this.description = description;
	}
 
	@OneToMany(mappedBy = "categorie")
	public Collection<Produit> getProduits() {
		return this.produits;
	}
 
 
	public void setProduits(Collection<Produit> produits) {
		this.produits = produits;
	}
	@Lob
	@Column(name = "Image", nullable = false)
	@Basic(fetch=FetchType.LAZY)
 
	public String getImage() {
		return image;
	}
 
	public void setImage(String image) {
		this.image = image;
	}
 
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "categorie")
	public Collection<Categorie> getCategories() {
		return this.categories;
	}
 
	public void setCategories(Collection<Categorie> categories) {
		this.categories = categories;
	}
 
	@Override
	public String toString() {
		return "Categorie [idCategorie=" + idCategorie + ", categorie="
				+ categorie + ", intitule=" + intitule + ", affiche=" + affiche
				+ ", description=" + description + "]";
	}
 
 
 
}
voila l'implémentation de la méthode
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
 
	public void delete(String intitule) {
		// TODO Auto-generated method stub
		Session session=sessionFactory.getCurrentSession();
		Query q=session.createQuery("from Categorie c where c.intitule =:intitule");
		q.setString("intitule",intitule);
		//Categorie c=(Categorie) q.uniqueResult();
		//System.out.println(c.getIntitule());
		session.delete((Categorie) q.uniqueResult());
 
	}
J'ajoute que dans j'ai implémenter une relation réflexive dans l'entité Categorie de tel sorte que chaque categorie soit liée à plusieurs catégories.
SVP quelqu'un peut m'aider