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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:35:57+00:00 2026-05-26T00:35:57+00:00

I have a parent/child database relationship between the table ACCOUNT and the table USER.

  • 0

I have a parent/child database relationship between the table ACCOUNT and the table USER. Currently I have mapped a bi-directional Fluent mappings like this:

public class Account {
  public virtual IList<User> ListUsers { get; private set; }

  public virtual void AddUser(User user)
  {
    user.Account = this;
    ListUsers.Add(user);
  }
}

MAPPING: HasMany(x => x.ListUsers).Table("UserInfo").KeyColumn("Id_Account").Inverse().Cascade.All().AsList();

public class User {
  public virtual Account Account { get; set; }
  public string Username { get; set; } 
}

MAPPING: References(x => x.Account).Column("Id_Account");

In practice I cannot foresee that I will ever want to reference the Account entity from the User entity. Likewise I cannot foresee my wanting to load all of the User entities from the parent Accounts entity. I am fairly new to NHibernate and was wondering is the above method still the best way to go performance wise? Is a bi-directional relationship preferred and should I look to referencing the Id only? 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-26T00:35:58+00:00Added an answer on May 26, 2026 at 12:35 am
    1. bi-directional references is the correct approach, in my opinion. If you use lazy-loading on the Account property, then it would only load the account’s id anyway.
    2. you specified that the ListUsers property is inverse=true, meaning the User entity is responsible for saving the reference. Therefore, I believe (if I remember correctly) that the line ListUsers.Add(user); is not necessary, since the association will be created by the User entity.
      So this means that you don’t have to load the entire ListUsers collection from the db when you add a user.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a parent-child relationship in an Oracle 9i database-table like: parent | child
I have the following table relationship in my database: Parent / \ Child1 Child2
I have a existing parent-child relationship I am trying to map in Fluent Nhibernate:
I have a parent-child relationship between two objects. Parent :has_many :children Child :belongs_to :parent
I have some Oracle tables that represent a parent-child relationship. They look something like
I have one-to-many relationship between parent and child Java objects. The parent object uses
I have a parent/child relationship via our users table, with models as such: class
I'm really upset with Hibernate! I have a database table (mysql) that holds parent-child
Given a parent child relationship between User and FailedLogin where a user has many
I have parent/child relationship set up via Node Reference. A Child record can have

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.