I hardly have any idea how to proceed when deleting. My problem is that if a category is associated to an issue, and I try to delete it from project, I should not be able to do that.
How can I do that? Help please.
I have 3 tables, Issue, Project, Category
The relationships are as follows: 1. A project may have many issues, an issue is related to only one project 2. An issue may have only one category 3. A project may have one or many categories
Issue.hbm.xml is as follows:
<id name="id" type="Int32" unsaved-value="0" access="field">
<column name="ID" length="4" sql-type="int" not-null="true" unique="true" index="PK_Issue"/>
<generator class="native" />
</id>
<many-to-one name="Project" class="API.Project, API">
<column name="ProjectID" length="4" sql-type="int" not-null="false"/>
</many-to-one>
<many-to-one name="Category" class="API.Category, API">
<column name="CategoryID" length="4" sql-type="int" not-null="false"/>
</many-to-one>
project.hbm.xml
<id name="id" type="Int32" unsaved-value="0" access="field">
<column name="ID" length="4" sql-type="int" not-null="true" unique="true" index="PK_Project"/>
<generator class="native" />
</id>
<property name="Name" type="String">
<column name="Name" length="200" sql-type="varchar" not-null="true" unique="true" index="IX_Project_Name"/>
</property>
category.hbm.xml
<id name="id" type="Int32" unsaved-value="0" access="field">
<column name="ID" sql-type="int" not-null="true" unique="true" index="PK_Category"/>
<generator class="native" />
</id>
<property name="Name" type="String">
<column name="Name" length="50" sql-type="varchar" not-null="true" unique="true" index="IX_Category"/>
</property>
<many-to-one name="Project" class="API.Project, API" >
<column name="ProjectID" length="4" sql-type="int" not-null="false"/>
</many-to-one>