<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
\"-//Hibernate/Hibernate Configuration DTD 2.0//EN\"
\"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd\"><!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration><session-factory>
<property name=\"connection.username\">root</property>
<property name=\"connection.url\">
jdbc:mysql://localhost:3306/pop
</property>
<property name=\"dialect\">
net.sf.hibernate.dialect.MySQLDialect
</property>
<property name=\"myeclipse.connection.profile\">mysql</property>
<property name=\"connection.password\">1982</property>
<property name=\"connection.driver_class\">
com.mysql.jdbc.Driver
</property>
<property name=\"show_sql\">true</property>
<mapping resource=\"com/chen/dao/config/droit.hbm.xml\" />
<mapping resource=\"com/chen/dao/config/actor.hbm.xml\" />
<mapping resource=\"com/chen/dao/config/user.hbm.xml\" />
</session-factory></hibernate-configuration>
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE hibernate-mapping PUBLIC \"-//Hibernate/Hibernate Mapping DTD 2.0//EN\" \"hibernate-mapping-2.0.dtd\" >
<hibernate-mapping>
<class name=\"com.chen.pojo.Actor\" table=\"actor\">
<id name=\"id\" column=\"id\" type=\"Integer\">
<generator class=\"increment\"></generator>
</id>
<property name=\"name\" column=\"droit_name\"></property>
<set name=\"droit\" cascade=\"all\">
<key column=\"droit_id\"></key>
<one-to-many class=\"com.chen.pojo.Droit\" />
</set>
</class>
</hibernate-mapping>
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE hibernate-mapping PUBLIC \"-//Hibernate/Hibernate Mapping DTD 2.0//EN\" \"hibernate-mapping-2.0.dtd\" >
<hibernate-mapping>
<class name=\"com.chen.pojo.Actor\" table=\"actor\">
<id name=\"id\" column=\"id\" type=\"Integer\">
<generator class=\"increment\"></generator>
</id>
<property name=\"name\" column=\"droit_name\"></property>
<set name=\"droit\" cascade=\"all\">
<key column=\"droit_id\"></key>
<one-to-many class=\"com.chen.pojo.Droit\" />
</set>
</class>
</hibernate-mapping>
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE hibernate-mapping PUBLIC \"-//Hibernate/Hibernate Mapping DTD 2.0//EN\" \"hibernate-mapping-2.0.dtd\" >
<hibernate-mapping>
<class name=\"com.chen.pojo.User\" table=\"user\">
<id name=\"id\" column=\"id\" type=\"Integer\">
<generator class=\"increment\"></generator>
</id>
<property name=\"name\" column=\"user_name\"></property>
<property name=\"password\" column=\"password\"></property>
<many-to-one name=\"actor\"
column=\"actor_id\"
class=\"com.chen.pojo.Actor\"
cascade=\"all\"
/>
</class>
</hibernate-mapping>
===================================报错误=====================
log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: com/chen/dao/config/droit.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at com.chen.factory.HibernateSessionFactory.currentSession(HibernateSessionFactory.java:48)
at com.chen.dao.UserDao.<init>(UserDao.java:19)
at com.chen.dao.test.UserTest.testAddUser(UserTest.java:36)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: net.sf.hibernate.MappingException: org.dom4j.DocumentException: Stopping after fatal error: File \"hibernate-mapping-2.0.dtd\" not found. Nested exception: Stopping after fatal error: File \"hibernate-mapping-2.0.dtd\" not found.
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:296)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
... 24 more
Caused by: org.dom4j.DocumentException: Stopping after fatal error: File \"hibernate-mapping-2.0.dtd\" not found. Nested exception: Stopping after fatal error: File \"hibernate-mapping-2.0.dtd\" not found.
at org.dom4j.io.SAXReader.read(SAXReader.java:358)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
... 25 more
高人指点
[此贴子已经被作者于2007-7-25 16:20:30编辑过]