在尝试为one to many
和Person
类实现Address
映射时,我收到以下异常:org.hibernate.MappingException: could not instantiate id generator
。
我不知道原因。我得到这个例外的原因是什么?
<class name="pojo.Person" table="person">
<id name="personID" column="p_id">
<generator class="increment" />
</id>
<property name="personName" column="p_name" />
<set name="addressSet" table="address" cascade="all">
<key column="p_id" />
<one-to-many class="pojo.Address" />
</set>
</class>
<class name="pojo.Address" table="address">
<id name="a_id" column="a_id">
<generator class="foreign" />
</id>
<property name="personAddress" column="p_address" />
</class>
创建表的SQL:
CREATE TABLE person(p_id INTEGER,p_name TEXT,PRIMARY KEY(p_id));
CREATE TABLE address(a_id INTEGER,p_address TEXT);
注意:一个人可以拥有多个地址