hibernate one2one 问题
来源:百度知道 编辑:UC知道 时间:2024/09/21 20:33:28
<?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>
<class name="po.School" table="SCHOOL">
<id name="sid" column="SID" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property name="sname" column="SNAME" />
<one-to-one name="herder" class="po.Herder" cascade="all"></one-to-one>
</class>
</hibernate-map
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="po.School" table="SCHOOL">
<id name="sid" column="SID" type="java.lang.Integer">
<generator class="assigned"/>
</id>
<property name="sname" column="SNAME" />
<one-to-one name="herder" class="po.Herder" cascade="all"></one-to-one>
</class>
</hibernate-map
Exception in thread "main" org.hibernate.exception.GenericJDBCException: could not load an entity: [po.School#2]
这一句,告诉你不能 装载 po.School 这个实体
看一下在数据库中,数据是不是一致,有没有作到一对一