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

  • SEARCH
  • Home
  • 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 6185993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:48:41+00:00 2026-05-24T01:48:41+00:00

I have the following tables : Basically, a user is part of a project

  • 0

I have the following tables :

enter image description here

Basically, a user is part of a project and has certain access rights on that particular project.

I created the following entities:

  1. User
  2. Project
  3. AccessRight

How can I map, using NHibernate, a User entity so that I can easily fetch the access rights per project he’s assigned to ?

I was thinking of doing the following:

  1. Create a new entity called “ProjectRight” which will have a Project ID as the primary key
  2. Create a “Many-To-Many” set within the User entity :

    public virtual ICollection<ProjectRight> ProjectRights { get; set; }

    And in the User mapping:

<set name="ProjectRights" table="Users_Projects_Rights">
  <key column="id_UserGroup"></key>
  <many-to-many class="ProjectRight" >
    <column name="id_Project" />
    <column name="id_AccessRight" />
  </many-to-many>
 </set>

Would this work ? And if yes, does that mean that I’ll need to create two additional entities so that I can map the Projects and AccessRights table..?

Thanks

  • 1 1 Answer
  • 0 Views
  • 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-24T01:48:41+00:00Added an answer on May 24, 2026 at 1:48 am

    I’d suggest creating ProjectRight as a component instead of an entity:

    <set name="ProjectRights" table="Users_Projects_Rights">
        <key column="id_User"/>
        <composite-element class="ProjectRight">
            <many-to-one name="Project" column="id_Project"/>
            <many-to-one name="Right" column="id_AccessRight"/>
        </composite-element>
    </set>
    

    This is one of the two ways suggested by the NHibernate documentation. For the other one see here.

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

Sidebar

Related Questions

I have the following xsl panels that are created depending on the user selecting
Suppose that we have following tables create table Employee( 2 EMPNO NUMBER(3), 3 ENAME
I have 2 tables: User and Picture. The Picture table has the key of
I have a database that has two tables. These two tables are defined as:
I have the following tables: Post Id int User Id int Then I have
In my project I have some tables that are not managed by Code First
I have following tables : users accounts ( user has_one account ) pictures (
I basically have two tables called images and users . The images table has
I have the following tables for my CakePHP app that allows friendships between users:
Is there any name for the following DB table design: Basically we have generic

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.