-->
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.  [ 6 posts ] 
Author Message
 Post subject: Erreur lors de la création de la SessionFactory
PostPosted: Mon Oct 17, 2005 2:59 pm 
Newbie

Joined: Thu Sep 29, 2005 1:20 pm
Posts: 16
Location: Brussel
J'ai un problème, en mode console sous Ecplise, lors de la création de la SessionFactory. Le message d'erreur est le suivant:

"could not read mapping from resource" : Employment.hbm.xml



Phaus


Hibernate version:
3.0
Mapping documents:


<?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">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://localhost/Usine
</property>
<property name="connection.username">root</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.MySQLDialect
</property>

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

<property name="hibernate.use_outer_join">true</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>

<mapping resource="Employee.hbm.xml"/>
<mapping resource="Employer.hbm.xml"/>
<mapping resource="Employment.hbm.xml"/>




</session-factory>

</hibernate-configuration>
---------------------------------------------------
Employment.hbm.xml
---------------------------------------------------

<?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="Employment" table="employment_periods">
<id name="id">
<generator class="increment"></generator>
</id>
<property name="startDate" column="start_date"/>
<property name="endDate" column="end_date"/>
<component name="hourlyRate" class="MonetoryAmount">
<property name="amount">
<column name="hourly_rate" sql-type="NUMERIC(12, 2)"/>
</property>
<property name="currency" length="12"/>
</component>
<many-to-one name="employer" column="employer_id" not-null="true"/>
<many-to-one name="employee" column="employee_id" not-null="true"/>
</class>
</hibernate-mapping>

---------------------------------------------------
Employer.hbm.xml
---------------------------------------------------
<?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="Employer" table="employers">
<id name="id">
<generator class="increment"></generator>
</id>
<property name="name" />
</class>
</hibernate-mapping>

---------------------------------------------------
Employee.hbm.xml
---------------------------------------------------
<?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="Employee" table="employees">
<id name="id">
<generator class="increment"></generator>
</id>
<property name="taxfileNumber" />
<component name="name" class="Name">
<property name="firstName" />
<property name="initial" />
<property name="lastName" />
</component>
</class>
</hibernate-mapping>


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:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 3:33 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Peut-être avez vous mal indiqué le répertoire dans lequel se retrouve le fichier de mapping Employment.hbm.xml.

Si votre fichier de mapping est situé:
src/com/your/package/Employment.hbm.xml

Vous devez changer votre fichier de configuration pour que le nom de package soit spéficié:

<mapping resource="com/your/package/Employment.hbm.xml"/>

J'espère que cela règlera votre problème. Si ce n'est pas le cas, incluez le stack trace complet de votre erreur dans votre message.

Bonne journée,
Vincent.

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 5:41 pm 
Newbie

Joined: Thu Sep 29, 2005 1:20 pm
Posts: 16
Location: Brussel
Je sais que c'est peut etre pour vous une question bete. Mais ou peut on trouver les messages de la stacktrace.?

Merci pour votre aide.


Phaus


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 17, 2005 6:02 pm 
Newbie

Joined: Thu Sep 29, 2005 1:20 pm
Posts: 16
Location: Brussel
Et puis ce qui me semble étrange, c'est que les deux autres fichiers de mappings fonctionnent tres bien sans le fichier de mapping suivant à savoir: Employment.hbm.org



Phaus


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 12:15 am 
Newbie

Joined: Wed Oct 12, 2005 9:20 pm
Posts: 16
Location: Sydney
Bonjour,

Le stacktrace est quelque chose du style :
Code:
2005-10-18 13:37:42,703 WARN  hibernate.util.JDBCExceptionReporter  - SQL Error: 0, SQLState: 07001
2005-10-18 13:37:42,718 ERROR hibernate.util.JDBCExceptionReporter  - No value specified for parameter 1
org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:65)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:2150)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2026)
   at org.hibernate.loader.Loader.list(Loader.java:2021)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1455)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:298)
   at com.siliconmemory.hibernate.factory.HddFactory.getListHddInUse(HddFactory.java:110)
   at com.siliconmemory.control.MainController.getListHddInUse(MainController.java:999)
   at com.siliconmemory.control.TableHardDriveController.getListHddInUse(TableHardDriveController.java:371)
   at com.siliconmemory.ui.table.TableHardDrive$15.widgetSelected(TableHardDrive.java:599)
   at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
   at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
   at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:843)
   at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3080)
   at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2713)
   at com.siliconmemory.ui.ApplicationUI.open(ApplicationUI.java:100)
   at com.siliconmemory.ui.ApplicationUI.main(ApplicationUI.java:83)
Caused by: java.sql.SQLException: No value specified for parameter 1
   at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1250)
   at com.mysql.jdbc.PreparedStatement.fillSendPacket(PreparedStatement.java:1198)
   at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:963)
   at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
   at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:137)
   at org.hibernate.loader.Loader.getResultSet(Loader.java:1676)
   at org.hibernate.loader.Loader.doQuery(Loader.java:662)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:223)
   at org.hibernate.loader.Loader.doList(Loader.java:2147)
   ... 16 more


Ca apparait (en therorie) en rouge dans la console d'eclispe.

Cela permet d'avoir plus d'information sur l'erreur.


Ben


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 18, 2005 1:33 am 
Newbie

Joined: Thu Sep 29, 2005 1:20 pm
Posts: 16
Location: Brussel
Merci pour l'information mais comme j'utilise le mode console je n'exécute pas encore du code, donc je n'ai pas de stacktrace mais juste un message d erreur dans une boite de dialogue.


Phaus


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