Bonjour,
J'essaye d'intégrer Hibernate à mon projet mais j'ai un soucis lorsque je souhaite récupérer les infos stockées en base.
J'arrive à faire un insert/update/delete sans problème.
Quand je souhaite récupérer les infos en base il me sort cette erreur.
Voici quelques infos.org.hibernate.hql.ast.QuerySyntaxException: Application is not mapped
Mon fichier cfg.xml
Le fichier qui mappe mon objet<session-factory
name="java:hibernate/SessionFactory">
<!-- properties -->
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/meteoservices</property>
<property name="hibernate.connection.username">meteo</property>
<property name="hibernate.connection.password">meteo</property>
<property name="hibernate.current_session_context_class">thread</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="session_factory_name">java:hibernate/SessionFactory</property>
<!-- mapping files -->
<mapping resource="Application.hbm.xml"/>
</session-factory>
Dans mon code je fais ceci<hibernate-mapping auto-import="false">
<class name="dto.Application" table="application">
<id name="id" column="id">
<generator class="increment"/>
</id>
<property name="libelle" column="libelle" type="string"/>
<property name="etat" column="etat" type="boolean"/>
</class>
</hibernate-mapping>
Avez vous une idée d'ou peux venir le problème.
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 List<Application> app= (List<Application>) getListObject("Application"); public List<?> getListObject(String className) { List<?> l = null; Session s = HibernateUtil.getSessionFactory().getCurrentSession(); s.beginTransaction(); try { Query q = s.createQuery("from " + className); l = q.list(); } catch (HibernateException he) { throw he; } catch (RuntimeException ex) { throw ex; } finally { s.close(); } return l; }
Merci de vos réponse.
Bonne journée.
Partager