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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T17:51:19+00:00 2026-05-11T17:51:19+00:00

My database structure looks something like this: Person Id Name FieldA FieldB Phone Id

  • 0

My database structure looks something like this:

Person
  Id
  Name
  FieldA
  FieldB

Phone
  Id
  Number

PersonPhone
  PhoneId
  PersonId
  IsDefault

My NHibernate mappings for the Person and Phone objects are straight forward, its the PersonPhone I’m having difficult with. I want to have a collection of PersonPhone objects as a property of Person which will allow me to have the Phone number of a person and be able to tell which is the “default” or primary phone number for a person.

ideally Id like my PersonPhone object to look like this:

public class PersonPhone
{
    public virtual Person Person { get; set; }
    public virtual Phone Phone { get; set; }
    public virtual bool IsDefault { get; set; }
}

so far my NHibernate mapping for this table looks like the following:

<class name="PersonPhone" table="PersonPhone">
    <composite-id>
        <key-property name="Person" column="PersonId" />
        <key-property name="Phone" column="PhoneId" />
    </composite-id>
    <property name="IsDefault" column="IsDefault"/>
</class>

but when NHibernate compiles my mappings I get an error saying:

Could not compile the mapping document: MyApp.Entities.PersonPhone.hbm.xml. NHibernate.MappingException : Could not determine type for: MyApp.Entities.Person, MyApp.Entities, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null, for columns: NHibernate.Mapping.Column(PersonId)

Any ideas on how this should be mapped?

  • 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-11T17:51:19+00:00Added an answer on May 11, 2026 at 5:51 pm

    The answer is to use the element in your composite key rather than the key-property

    <class name="PersonPhone" table="PersonPhone">
        <composite-id>
            <key-many-to-one name="Person" column="PersonId"></key-many-to-one>
            <key-many-to-one name="Phone" column="PhoneId"></key-many-to-one>
        </composite-id>
        <property name="IsDefault" column="IsDefault"/>
    </class>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge data set. The structure looks something like this: K_Field1, K_Field2,
I have something that looks like the following document structure: public class Document {
The basic table schema looks something like this (I'm using MySQL BTW): integer unsigned
I have a database structure that has a Person table which contains fields such
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I need to be able to store something like this: where the green is
I have a hierarchical class structure like this: Category -> Template -> Instance A
This is not a homework. Visually it looks like a tree, but all leafs
I'm looking at a table structure that might look about like this: | char(32)
Specifically, I want to convert the XML structure into this format for the database

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.