-->
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.  [ 7 posts ] 
Author Message
 Post subject: Debutant : HQL
PostPosted: Thu Sep 29, 2005 1:32 pm 
Newbie

Joined: Thu Sep 29, 2005 1:20 pm
Posts: 16
Location: Brussel
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
3.0
Mapping documents:

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:

Je débute avec Hibernate 3.0.
Je suis en train de réaliser l'exemple fournit dans la documentation officielle d'hibernate 3.0. (la classe Event).
Lors du "store", apparament, les objets sont bien placés en mémoire.
Mais lorsque je veux les "lister", j'ai l'erreur suivante:

org.hibernate.exception.SQLGrammarException: could not execute

La requête HQL est la suivante:
queryList result = session.createQuery("from Event").list();

Cela fait qqs jours que je cherche sans résultat.

Merci de m'aider.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 4:25 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Vous devriez suivre la procédure et inclure le stacktrace et les documents de mappings.

Peut-être que vous tentez de faire votre requête sur le nom de la table et non pas sur l'entité.

Essayez d'exécuter: queryList result = session.createQuery("from " Event.class.getName()).list();

Si cela ne fonctionne pas, envoyez vos fichiers de mapping et le stack trace complet de l'erreur qui vous est retrounée.



Bonne chance :)
Vincent.

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 3:49 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Est-ce que cela a résolu votre problème?

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 12:44 pm 
Newbie

Joined: Thu Sep 29, 2005 1:20 pm
Posts: 16
Location: Brussel
Non malheureusement.

voici le stackstrace :

log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Hibernate: select event0_.EVENT_ID as EVENT1_, event0_.EVENT_DATE as EVENT2_0_, event0_.title as title0_ from EVENTS event0_
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute query
at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.doList(Loader.java:1518)
at org.hibernate.loader.Loader.list(Loader.java:1498)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:369)
at org.hibernate.hql.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:266)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:788)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at EventManager.listEvents(EventManager.java:60)
at EventManager.main(EventManager.java:25)
Caused by: java.sql.SQLException: Table not found in statement [select event0_.EVENT_ID as EVENT1_, event0_.EVENT_DATE as EVENT2_0_, event0_.title as title0_ from EVENTS event0_]
at org.hsqldb.jdbc.Util.throwError(Unknown Source)
at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:379)
at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:320)
at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:86)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1089)
at org.hibernate.loader.Loader.doQuery(Loader.java:365)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:206)
at org.hibernate.loader.Loader.doList(Loader.java:1515)
... 7 more


------------------------------------------------------------------------------------

et le fichier de mapping:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="connection.url">jdbc:hsqldb:data/tutorial</property>
<property name="connection.username">sa</property>
<property name="connection.password"></property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.HSQLDialect</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<!-- Drop and re-create the database schema on startup -->

<property name="hbm2ddl.auto">create</property>
<mapping resource="Event.hbm.xml"/>

</session-factory>


-------------------------------------


Merci de m'aider


Phaus

[/list]


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 03, 2005 6:12 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
J'aimerais voir le contenu de:

Event.hbm.xml

Y a-t-il une table dans votre base de données qui s'appelle EVENTS?

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 2:56 am 
Newbie

Joined: Thu Sep 29, 2005 1:20 pm
Posts: 16
Location: Brussel
Le fichier de mapping est le suivant:


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="Event" table="EVENTS">
<id name="id" column="EVENT_ID">
<generator class="increment"/>
</id>
<property name="date" type="timestamp" column="EVENT_DATE"/>
<property name="title"/>
</class>

</hibernate-mapping>
-----------------------------------------------------------------------


Merci de votre aide


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 04, 2005 3:02 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
On dirait que tout est correct.

Êtes-vous certain de bien avoir une table appelée EVENT dans votre base de données lorsque vous exécutez la requête?

Je vois que vous utilisez la propriété <property name="hbm2ddl.auto">create</property> .

Avez-vous des messages d'erreurs vous informant qu'il vous est impossible de créer la table EVENTS lorsque vous démarrez l'application?

_________________
Vincent Giguère
J2EE Developer


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

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.