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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T04:12:49+00:00 2026-05-11T04:12:49+00:00

I have a problem. Imagine this data model: [Person] table has: PersonId, Name1 [Tag]

  • 0

I have a problem. Imagine this data model:

[Person] table has: PersonId, Name1   [Tag] table has:  TagId, TagDescription   [PersonTag] has: PersonId, TagId, IsActive 

Since [PersonTag] isn’t just a simple many-to-many join table, I have all three entities created in nHibernate (exactly like they are in the data model). PersonTag, therefore, needs a composite-id, which I have mapped to a class like this:

<composite-id name='PersonTagKey' class='PersonTagKey'>   <key-property name='PersonId'></key-property>   <key-property name='TagId'></key-property> </composite-id>  

I want to traverse the object graph and be able to look at both the Person and Tag objects from a retrieved PersonTag object. So, I have properties on the PersonTag object to do that, mapped like this:

<many-to-one name='Person' column='PersonId' lazy='proxy' cascade='none' class='Person'/> <many-to-one name='Tag' column='TagId' lazy='proxy' cascade='none' class='Tag'/> 

When I try to create a PersonTag object and save it, I get an ‘Invalid index n for this SqlParameterCollection with Count=n’ error. I know this is because I’ve mapped the PersonId and TagId properties twice, once for the composite-id, and once for the many-to-one relationship. If I don’t map the many-to-one objects, then everything works fine.

Is there some way for me to be able to have a composite-id AND a many-to-one relationship based on the same column modeled in the same nHibernate entity?

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T04:12:49+00:00Added an answer on May 11, 2026 at 4:12 am

    Kay, here’s the answer. Little-to-no documentation on this:

    <composite-id name='PersonTagKey' class='PersonTagKey'>    <key-many-to-one name='Person' column='PersonId' lazy='proxy' class='Person'>   <key-many-to-one name='Tag' column='TagId' lazy='proxy' class='Tag'/> </composite-id> 

    This will allow you to create a composite-id made up of the inverse of a many-to-one relationship.

    Good hunting…

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

Sidebar

Ask A Question

Stats

  • Questions 75k
  • Answers 75k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I would just use.. try: float(element) except ValueError: print "Not… May 11, 2026 at 2:51 pm
  • added an answer If I change the values in a few textboxes then… May 11, 2026 at 2:51 pm
  • added an answer Why don't you use LINQ to SQL? Even if you… May 11, 2026 at 2:51 pm

Related Questions

I've been working on this for a few days now, and I've found several
I have a Jena ontology model ( OntModel ) which I'm modifying programatically. This
I am curious what strategies folks have found for unit testing a data access
Lets imagine I have the same database schema as here: http://www.databaseanswers.org/data_models/driving_school/index.htm If a customer

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.