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 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
  • 2 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. 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

Related Questions

I’m working on a multi dimensions array but i have a problem Imagine I
i have problem to correctly bind data to WPF Chart. When i'm setting ItemsSource
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
I've got a slightly tricky problem to solve; imagine this: One of my applications
I have problem to convert a classic input data with reshape My input data
In F#, imagine we have an array of bytes representing pixel data with three
Imagine I have a data bound ListView and in the <ControlTemplate.Triggers> I have the
I have a Jena ontology model ( OntModel ) which I'm modifying programatically. This
Lets say I have this data set: id city result fruit 1 boston good
Ok, let's imagine I have an object like this: public class User { public

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.