-->
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.  [ 2 posts ] 
Author Message
 Post subject: [débutant] Erreur Table not found en suivant le tutoriel…
PostPosted: Sat Jul 30, 2005 1:10 pm 
Newbie

Joined: Sat Jul 30, 2005 12:57 pm
Posts: 6
Salut à tous,

Je suis en train de faire le tutoriel d'Hibernate fourni ici et je suis tombé sur une erreur étonnante.

(j'ai suivi à la lettre le tutoriel, en copiant/collant les codes et fichiers xml).

Lorsque je build l'app avec ant et l'argument "store", il crée la base, store un Event et tout fonctionne bien. Lorsque je veux utiliser l'argument "list", je dois effacer un morceau du fichier hibernate.cfg.xml.
Ce morceau, c'est celui-ci:

<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>

Le problème, c'est qu'une fois cet élément effacé, j'ai à chaque fois une erreur "Table not found" lorsque je lance l'app avec l'argument "store".

Pouvez-vous me donner un petit coup de main ? :-)

Hibernate version:
3.0.5

Mapping documents:
<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>

Code between sessionFactory.openSession() and session.close():
Event theEvent = new Event();
theEvent.setTitle("title");
theEvent.setDate(new Date());
session.save(theEvent);
tx.commit();

Full stack trace of any exception that occurs:
[java] 18:54:52,141 WARN JDBCExceptionReporter:71 - SQL Error: -22, SQLState: S0002
[java] 18:54:52,154 ERROR JDBCExceptionReporter:72 - Table not found in statement [select max(EVENT_ID) from EVENTS]
[java] Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not fetch initial value
[java] at org.hibernate.exception.ErrorCodeConverter.convert(ErrorCodeConverter.java:70)
[java] at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
[java] at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:107)
[java] at org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:45)
[java] at org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:85)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:184)
[java] at org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
[java] at org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
[java] at org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
[java] at org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
[java] at EventManager.createAndStoreEvent(Unknown Source)
[java] at EventManager.main(Unknown Source)
[java] Caused by: java.sql.SQLException: Table not found in statement [select max(EVENT_ID) from EVENTS]
[java] at org.hsqldb.jdbc.Util.throwError(Unknown Source)
[java] at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
[java] at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
[java] at org.hibernate.id.IncrementGenerator.getNext(IncrementGenerator.java:86)
[java] ... 11 more
[java] Java Result: 1


Name and version of the database you are using:
HSQLDB, dernière version téléchargée aujourd'hui même:1.8.0.1

The generated SQL (show_sql=true):
select max(EVENT_ID) from EVENTS


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 30, 2005 1:11 pm 
Newbie

Joined: Sat Jul 30, 2005 12:57 pm
Posts: 6
Pour préciser: l'extrait du tutoriel qui explique comment changer le fichier de config…


Quote:
If you now call Ant with -Daction=list, you should see the events you have stored so far. You might be surprised that this doesn't work, at least if you followed this tutorial step by step - the result will always be empty. The reason for this is the hbm2ddl.auto switch in the Hibernate configuration: Hibernate will re-create the database on every run. Disable it by removing the option, and you will see results in your list after you called the store action a few times. Automatic schema generation and export is mostly useful in unit testing.



ps: pas d'édit de posts ici?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.