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
voici l'arboresence de mon projet
voici mon fichier hibernate.cfg.xml :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10 src +money.config ++TestClass.hbm.xml +money.javabeans ++TestClass.java +hibernate.cfg.xml webroot +WEb-INF ++test.jsp
voici mon fichier de mapping :
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 <?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>
j'essaie désesperement de générer la base de donnée avec du code dans une jsp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <?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'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 : 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
20 ... <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 : 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
20
21
22
23
24
25 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)
Partager