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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:48:34+00:00 2026-05-16T07:48:34+00:00

I have a User table defined like this: CREATE TABLE Users( UserId int IDENTITY(1,1)

  • 0

I have a User table defined like this:

CREATE TABLE Users(
    UserId int IDENTITY(1,1) NOT NULL,
    UserName varchar(128) NOT NULL,
    Name nvarchar(200) NOT NULL,
    Password binary(64) NOT NULL,
    PasswordSalt binary(16) NOT NULL
)

I’m trying to have two class that map to this table:

  • The first object, called User has no Password and PasswordSalt properties.
  • The second object, called SecurityUser, inherits from User and defines the Password and PasswordSalt properties.

The idea behind this is that SecurityUser is a internal object that require a intermediate service to modify the password. This is needed to avoid returning the password and salt everytime I need to query a user.

The User class is, what I call, a safe object that doesn’t provide any user sensitive information.

Right now, I have defined two map:

public class UserMap : ClassMap<User>
{
    protected UserMap()
    {
        Id(x => x.Id);
        Map(x => x.UserName);
        Map(x => x.Name);
    }
}

and

public class SecurityUserMap : SubclassMap<SecurityUser>
{
    protected SecurityUserMap()
    {
        Map(x => x.Password);
        Map(x => x.PasswordSalt);
        Table("Users");
    }
}

The problem is that nHibernate creates a table called SecurityUser. I tried using the Table("Users") function to specify the same table, but I then get a invalid nhibernate mapping.

How can I achieve what I am trying to do? Or is there is an alternate approach?

  • 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-16T07:48:35+00:00Added an answer on May 16, 2026 at 7:48 am

    NHibernate does not know when to save a User and when to save a security user. You need something in your database to tell NHibernate when a record is a user, and when it is a security user.
    To tell you how do to that, I need to know why “This is needed to avoid returning the password and salt everytime I need to query a user.”? When the reason is performance, You can probably not measure the difference. If you use the User class for reporting scenario’s, you can better use a projection class to select the result of the reporting queries to, than a mapped entity.

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

Sidebar

Related Questions

I have a table defined like this: CREATE TABLE mytable (id INT NOT NULL
I have three tables to define users: USER: user_id (int), username (varchar) USER_METADATA_FIELD: user_metadata_field_id
I have a user table 'users' that has fields like: id first_name last_name ...
I have a user table like this FIRSTNAME | LASTNAME | ID | --------------------------------
I've noticed something odd about user-defined variables: Lets say I have this table: num_table
I have an user defined table function in SQL Server that aggregate data from
I have a user-defined table type. I want to check it's existence before editing
I have a stored procedure which accepts a User defined table type called SeasonTable
I have a table a with a list of id's, and a user-defined function
I have three tables which are defined as: class User(Base): __tablename__ = 'users' id

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.