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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:27:03+00:00 2026-05-11T20:27:03+00:00

When automapping a joined subclass in fluent nhibernate, I can’t figure out how to

  • 0

When automapping a joined subclass in fluent nhibernate, I can’t figure out how to give the joined subclass a primary key.

public class Address:Entity {
    public virtual string Address1 { get; set; }
    public virtual string Address2 { get; set; }
    public virtual string City { get; set; }
    public virtual string State { get; set; }
    public virtual string Zip { get; set; }
    public virtual string Phone { get; set; }
    public virtual string Fax { get; set; }
    public virtual IList<Location> Locations { get; set; }
}

public class Location:Address {
    public virtual Address BillingAddress { get; set; }
    public virtual string OfficeHours { get; set; }
    public virtual string PatientAgeRestrictions { get; set; }
    public virtual bool WheelchairAccess { get; set; }
    public virtual string ContactPerson { get; set; }
    public virtual string ContactEmail { get; set; }
    public virtual string ContactPhone { get; set; }
    public virtual string ContactFax { get; set; }
    public virtual string TaxId { get; set; }
}

I want Location to have it’s own id “location_ id” with it’s own sequence. Then I want that mapped to address through an address_id column.

Right now it’s generating the location with “addressid” as the primary key, which isn’t what I want. How do I change this with the automapping?

  • 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-11T20:27:03+00:00Added an answer on May 11, 2026 at 8:27 pm

    I’m not sure you have a joined-subclass relationship. That is, by definition a joined subclass has the same ID as its parent class. For example, you might have a Person entity stored in your database for generic “people” information like name/age/etc and then an Employee subclass entity which is stored in a different table and holds data like position, salary, and dates of employment. So an Employee is a subtype of Person and to get the full “Employee-Person” object, you must join the two tables on their primary keys (e.g. SELECT * FROM Employee INNER JOIN Person ON Employee.Employee_id = Person.Person_id).

    Are you sure about your relational model here? Is Location truly a subtype of Address? Inferring a bit from your property names, it seems to me that this is not what you intend. It seems like you probably have a many-to-many between an Address and an Organization (that is, there may be many “organizations” at the same address and an “organization” may have many addresses), with a “contact person” for the organization at a specific address. In which case you should map “organization”, “contact”, and another entity that defines the relationship between Address and “organization”.

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

Sidebar

Related Questions

I'm trying out the automapping capability of Fluent NHibernate, and the same code that
I am experimenting with NHibernate (version 2.1.0.4000) with Fluent NHibernate Automapping. My test set
I'm using the following mapping: public class LoadMap : IAutoMappingOverride<Load> { public void Override(AutoMapping<Load>
I am using FluentHibernate and Automapping. My classes are public class Student { public
I'm trying to make Fluent NHibernate's automapping ignore a Dictionary property on one of
I am using Fluent NHibernate's (1.0 RTM) automapping feature to create my oracle database
I have a Sharp Architecture based app using Fluent NHibernate with Automapping. I have
Is there a way to use Rhino.Commons with Fluent Nhibernate, (in particular AutoMapping)? Many
Using Fluent NHibernate, I cannot seem to devise the necessary automapping conventions for the
We are using Fluent NHibernate with automapping for our objects. Something like: AutoPersistenceModel autoMap

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.