Reputation: 23276
While trying to achieve one to many
mapping for class Person
and Address
I get the following exception :org.hibernate.MappingException: could not instantiate id generator
.
I don't know the reason for this. What could be the reason I am getting this exception ?
<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 that created table:
CREATE TABLE person(p_id INTEGER,p_name TEXT,PRIMARY KEY(p_id));
CREATE TABLE address(a_id INTEGER,p_address TEXT);
Note: One person can have more than one address
Upvotes: 1
Views: 11895
Reputation: 3679
You need to change generator class from foreigner
to increment
in a key of your Address entity. For details, see this answer where I already mentioned that.
Upvotes: 2