【发布时间】:2012-08-14 14:08:38
【问题描述】:
我遇到了异常
Initial SessionFactory creation failed.org.hibernate.MappingException:来自表 CountryList 的关联引用了一个未映射的类:com.abegaa.model.StateListPojo
这两个hbm文件之间的hibernate映射
第一个 CountryList 和 StateList
<?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.abegaa.model">
<class name="CountryListPojo" table="CountryList">
<id name="Id" column="Id">
<generator class="increment"></generator>
</id>
<many-to-one name="Db_CountryId" column="Db_CountryId" class="StateListPojo"></many-to-one>
<property name="Db_CountryName" column="Db_CountryName"></property>
</class>
</hibernate-mapping>
和
<?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.abegaa.model">
<class name="StateListPojo" table="StateList">
<id name="Id" column="Id">
<generator class="increment"></generator></id>
<set name="Db_CountryId">
<key column="Db_CountryId"></key>
<one-to-many class="CountryListPojo"/>
</set>
<property name="Db_StateId" column="Db_StateId"/>
<property name="Db_StateName" column="Db_StateName"/>
</class>
</hibernate-mapping>
这是我的课。
public class CountryListPojo
{
private long Id;
private String Db_CountryId;
private String Db_CountryName;
//get and set
}
public class StateListPojo
{
private String Id;
private String Db_CountryId;
private String Db_StateId,Db_StateName;
//get and set
}
我不明白我哪里做错了?
【问题讨论】:
-
1) 请使用正确的 Java 命名约定。 2)没有对任何集合的引用。设置
标签: hibernate hibernate-mapping