I am new to hibernate world, still learning it. I am trying to persist one class in database using hibernate. Objects of this class can have different meaning in its client classes. Following is the class definition which I want to persist :
class Entity {
int id;
String name;
}
class ClientClass {
int clientClassID;
List<Entity> employerList;
List<Entity> clientList;
}
Mapping file for ClientClass is as follows :
<hibernate-mapping package="com.foo.bar.model">
<class name="ClientClass" table="CLIENTS">
<id name="clientClassID" column="CLIENT_ID" type="integer"
unsaved-value="0">
<generator class="native" />
</id>
<set name="clientList" table="PROJECT_CLIENTS" cascade="all">
<key column="CLIENT_ID" />
<many-to-many column="CLIENT_ID" class="Entity" />
</set>
<property name="description" type="string" length="1000" />
<set name="employerList" table="PROJECT_EMPLOYERS" cascade="all">
<key column="CLIENT_ID" />
<many-to-many column="EMPLOYER_ID" class="Entity" />
</set>
</class>
</hibernate-mapping>
I am not able to understand how to write mappings for Entity class?
Please help me. If you need more details then please let me know.
Thanks in Advance !!!