Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 980429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:22:46+00:00 2026-05-16T04:22:46+00:00

I hardly have any idea how to proceed when deleting. My problem is that

  • 0

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>
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:22:47+00:00Added an answer on May 16, 2026 at 4:22 am

    I am assuming in your database you have foreign keys for the referenced ID’s? (if not you should do). In which case the foreign-key attribute in your mapping is required, and currently it looks like it is missing.

    e.g. for issue.hbm.xml it may look something like this:

    <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" foreign-key="FK_Issue_Project"> 
      <column name="ProjectID" length="4" sql-type="int" not-null="false"/> 
    </many-to-one> 
    <many-to-one name="Category" class="API.Category, API" foreign-key="FK_Issue_Category"> 
      <column name="CategoryID" length="4" sql-type="int" not-null="false" /> 
    </many-to-one>
    

    The FK names I’ve put in here are just assumptions, go and check out what they are in your DB to make sure they are correct.

    Once NHibernate knows about your FK relationships it should take care of the rest 🙂

    EDIT:

    OOPs – the foreign-key property should be in the many-to-one element not the column sorry. See amended code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem so strange that I hardly can put an adequate title
There is so much written about unit testing but I have hardly found any
I am new on iphone development and I have problem with CoreData. I hardly
I hardly see any pointer on the following problem related to Hibernate. This pertains
This is probably really simple but I have hardly any experience with classic ASP
I have a C++/CLI class library project in VS2005 that i am having some
I saw plenty of similar questions on SO but hardly any of them have
I have a machine that is running Ubuntu Hardy, which provides its own RubyGems
The title is hardly understandable, but I'm not sure how to summarize that another
Before I start, I should let you know that I'm hardly experienced in PHP.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.