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 348127
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:20:08+00:00 2026-05-12T11:20:08+00:00

I have tables like this: tblUsers int UserID string UserName tblUsersInRoles int UserID int

  • 0

I have tables like this:

tblUsers
int UserID
string UserName


tblUsersInRoles
int UserID
int RoleID

tbleRoles
int RoleID
string RoleName

A user can be in many roles.

Is there a way to create my mapping file for my users so that my users object contains a list of Roles? I’ve figured out to do it so that I have a list of RoleID’s like this:

<bag name="Roles" table="tblUsersInRoles" cascade="all">
  <key column="UserId"/>
  <one-to-many class="UsersInRoles"/>
</bag>

Is there a way to take that the next step via the mapping file and store the roles themselves instead of just their ID’s?

Thanks for any help

  • 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-12T11:20:09+00:00Added an answer on May 12, 2026 at 11:20 am

    You dont need UsersInRoles, to do it you can use this mapping:

    <bag name="Roles" table="tblUsersInRoles" cascade="none"> 
      <key column="UserId"></key> 
      <many-to-many class="Role" column="RoleId"></many-to-many> 
    </bag> 
    

    And you can read this post about many to many. And about cascading – if you set cascade to all then deleting of user will couse deleting of his roles – I don’t think you need it.

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

Sidebar

Related Questions

I have 2 tables which in simplified form look like this: Products( id: int,
I have 2 tables: posts tags Tags table is structured like this: post_id tag
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have several sources of tables with personal data, like this: SOURCE 1 ID,
I have 2 tables like this Table 1 Id f1 f2 1 ABC red,green
So what I want is to have some tables like this <ul> <li>Some Text,
I have a mysql problem. I have two tables like this that I need
I have 3 tables that look like this: tblVideo: VideoID | Video Name 1
I have two tables that look like this: Table: cases id name status case_no
I have a CMS system that stores data across tables like this: Entries Table

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.