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: probleme de mappig et de génération de base de donnée
PostPosted: Mon Nov 26, 2007 1:43 pm 
Newbie

Joined: Wed Dec 13, 2006 9:34 am
Posts: 6
Bonjour
je débute avec hibernate j'ai un petit soucis je désire générer les tables de la base de données a partir des fichiers de mapping

Hibernate version: 3.0

Mapping documents:

Arborescence de mon projet

Code:
src
+money.config
++TestClass.hbm.xml
+money.javabeans
++TestClass.java
+hibernate.cfg.xml
webroot
+WEb-INF
++test.jsp


hibernate.cfg.xml
Code:
<?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>
   <property name="connection.username">sylvain</property>
   <property name="connection.url">jdbc:mysql://localhost:3306/money</property>
   <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
   <property name="myeclipse.connection.profile">mysql money</property>
   <property name="connection.password">6LMmar1e</property>
   <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
   <property name="hbm2ddl.auto">create</property>
   <property name="show_sql">true</property>
   <mapping resource="money/config/TestClass.hbm.xml" />   
</session-factory>
</hibernate-configuration>


mon fichiermoney /config/TestClass.hbm.xml"

Code:
<?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 package="money.javabeans">
  <class name="TestClass" table="TESTCLASSE"  lazy="false">        
     <id name="i" column="i" type="java.lang.Integer">
        <generator class="native" />
     </id>
     <property name="a" column="a" type="java.lang.Integer" not-null="true"             length="10" />
  </class>
</hibernate-mapping>


j'essaie désesperement de générer la base de donnée avec du code dans une jsp :


Code:
...
<title>Insert title here</title>
</head>
<body>
<%

   Configuration cfg = new Configuration()
      .addResource("money/config/TestClass.hbm.xml");

   cfg.configure(new File("C:/Documents and Settings/sly33/workspace/Money/src/hibernate.cfg.xml"));


   SchemaExport sce = new SchemaExport(cfg);
   sce.setOutputFile("c:/test.sql");
   sce.create(true,true);

%>
</body>
</html>



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

Full stack trace of any exception that occurs:

j'ai une erreur sur la premiere ligne de code qui consiste à rajouter une ressource à la configuration que je n'arrive vraiment pas a résoudre quelqu'un peut il m'aider ?

Code:
exception

org.apache.jasper.JasperException: Could not read mappings from resource: money/config/TestClass.hbm.xml
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

cause mère

org.hibernate.MappingException: Could not read mappings from resource: money/config/TestClass.hbm.xml
   org.hibernate.cfg.Configuration.addResource(Configuration.java:485)
   org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1465)
   org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1433)
   org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1414)
   org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1390)
   org.hibernate.cfg.Configuration.configure(Configuration.java:1344)
   org.apache.jsp.test_jsp._jspService(test_jsp.java:72)
   org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
   org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
   org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
   javax.servlet.http.HttpServlet.service(HttpServlet.java:802)





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: Sat Dec 01, 2007 3:15 am 
Newbie

Joined: Wed Dec 13, 2006 9:34 am
Posts: 6
personne ne peut m'aider ?


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.