Hibernate 映射文件问题 求助
控制台如下
:
Exception in thread "main"
java.lang.ExceptionInInitializerError at com.sias.TestMany2one.query(TestMany2one.java:40)
at com.sias.TestMany2one.main(TestMany2one.java:11)
Caused by:
org.hibernate.MappingException: Association references unmapped class: Dancer
at org.hibernate.cfg.HbmBinder.bindCollectionSecondPass(HbmBinder.java:2503)
at org.hibernate.cfg.HbmBinder$CollectionSecondPass.secondPass(HbmBinder.java:2782)
at org.hibernate.cfg.CollectionSecondPass.doSecondPass(CollectionSecondPass.java:65)
at org.hibernate.cfg.Configuration.originalSecondPassCompile(Configuration.java:1716)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1423)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at com.sias.utils.HibernateUtil.<clinit>(HibernateUtil.java:13)
... 2 more
注: 我自己感觉路径都对,但是就是通不过。求助,求助。。
Dancer.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 package="com.sias">
<class name="Dancer">
<id name="id">
<generator class="native"/>
</id>
<property name="name" />
<many-to-one name="coach" column="coach_id"/>
</class>
</hibernate-mapping>
Hibernate.cfg.xml 文件如下:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/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/hibernate</property>
<property name="connection.username">root</property>
<property name="connection.password">tom</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>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/sias/Singe