bonjour a tous,
ça fait 2 jours que je travaille avec hibernate le problème que je faire une sélection d'éléments dont l'id de l'élément en question est égale à une variable de type integer n .

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
select f from Formation f where f.formationId = n
et l'erreur est:
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
 
java.sql.SQLException: null,  message from server: "Unknown column 'n' in 'where clause'"
	com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1905)
	com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1109)
	com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1203)
	com.mysql.jdbc.Connection.execSQL(Connection.java:2090)
	com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1496)
	org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
	org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
	org.hibernate.loader.Loader.doQuery(Loader.java:674)
	org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
	org.hibernate.loader.Loader.doList(Loader.java:2220)
	org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
	org.hibernate.loader.Loader.list(Loader.java:2099)
	org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:378)
	org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:338)
	org.hibernate.engine.query.HQLQueryPlan.performList(HQLQueryPlan.java:172)
	org.hibernate.impl.SessionImpl.list(SessionImpl.java:1121)
	org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
	dao.FormationDao.delete(FormationDao.java:90)
	sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	java.lang.reflect.Method.invoke(Method.java:597)
	com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
	com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
	javax.faces.component.UICommand.broadcast(UICommand.java:312)
	javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
	javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
	com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
et voici le fichier de mapping Formation.hbm.xml
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
 
<?xml version="1.0" encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
                            "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
                            "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping package="dto">
	<class name="Formation" table="formation">
		<id name="formationId" column="formation_id"
			type="java.lang.Integer">
			<generator class="increment" />
		</id>
		<property name="sujet" column="sujet" type="java.lang.String" />
		<property name="formateur" column="formateur"
			type="java.lang.String" />
		<property name="date" column="date" type="java.lang.String" />
		<property name="duree" column="duree" type="java.lang.String" />
	</class>
</hibernate-mapping>
et merci d'avance
Best regards & Cordialement.