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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T16:19:27+00:00 2026-05-15T16:19:27+00:00

I am using NHibernate for an ecommerce site and am having difficulty getting what

  • 0

I am using NHibernate for an ecommerce site and am having difficulty getting what should be a simple mapping to work. Essentially I have a ContactDetails entity which is used to save contact details for any type of user – Buyer/Seller/Advertiser/etc. I use an “any” mapping to allow a single table to hold contact_details for each type. The ID is written to contact_details_id and the type (buyer/seller/advertiser) to the contact_details_type field as follows.

<class name="ContactDetails" table="contact_details">

<id name="ID">
  <generator class="hilo" />
</id>

<any name="Party" id-type="System.Int32" meta-type="System.String" cascade="all">
  <meta-value value="buyer" class="Buyer" />
  <meta-value value="seller" class="Seller" />
  <column name="contact_details_type" />
  <column name="contact_details_id" />
</any>

In my buyer mapping I have a one-to-one with contact details which looks as follows

<one-to-one name="ContactDetails" class="ContactDetails" cascade="all" />

This all looks fine and I am able to save contactdetails to the database. My issue is that when I attempt to load a Buyer from the database the ContactDetails is not returned. Rather than joining on the contact_details_id field the generated query joins on the ID field of the contact_details table. I have tried everything possible but no matter what happens I cannot get the code to join on the right field (contact_details_id). Has anyone attempted this and, if so, how did it work? Please let me know if additional detail is rquired.

Thanks in advance,

JP

  • 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-15T16:19:28+00:00Added an answer on May 15, 2026 at 4:19 pm

    one-to-one is not supported for implicit polymorphism.

    Alternatives:

    • Create a superclass of Buyer and Seller if you don’t have one (you can call it Party), map the hierarchy using any strategy other than implicit, and use a regular one-to-one or many-to-one relationship instead of any (preferred)
    • Don’t map the relationship in Buyer and use a query instead

    (the limitations of the implicit polymorphism approach are highlighted here: http://nhibernate.info/doc/nh/en/index.html#inheritance-limitations)

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

Sidebar

Related Questions

Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA
I am using NHibernate as my ORM solution and have a need for a
We are using Nhibernate as our data access layer. We have a table of
We're developing a new eCommerce website and are using NHibernate for the first time.
Using NHibernate from C# and only HQL (not SQL) in a way that is
Using NHibernate ICriteria and adding .AddOrder ... I want to sort by a property
I'm using NHibernate 2 and PostgreSQL in my project. SchemaExport class does a great
I'm using nhibernate to store some user settings for an app in a SQL
I'm using NHibernate on a project and I need to do data auditing. I
I'm using NHibernate mappings as a defining schema for my app in the development

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.