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

The Archive Base Latest Questions

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

I am having some redundant primary key issues. I have an Item which contains

  • 0

I am having some redundant primary key issues.

I have an Item which contains many reports. I have mapped them as shown below. I can do Session.QueryOver(Of Item).List and there are no extra columns generated. I can also do Session.QueryOver(Of Report).List and there are no extra columns generated.

However, once I try to traverse the relationship from Item to Reports, I get the SQL query shown below. Can anyone tell me why? Thanks in advance!

Item Mapping:

Public Class ItemMapping
    Inherits ClassMap(Of Item)
    Public Sub New()
        Table("Items")
        Id(Function(x) x.ItemID)
        HasMany(Function(x) x.Reports).KeyColumn("ItemID").Inverse().Cascade.All()
    End Sub
End Class

Report Mapping:

Public Class ReportMapping
    Inherits ClassMap(Of Report)
    Public Sub New()
        Table("Reports")
        Id(Function(x) x.ReportID)
        References(Function(x) x.Item).Column("ItemID")
        Map(Function(x) x.ReportName)
    End Sub
End Class

SQL Result:

SELECT repor0_.ItemID as ItemID1_, 
repor0_.ReportID as Rep1_1_, 
repor0_.ReportID as Rep1_4_0_, 
repor0_.ReportName as Rep2_4_0_, 
repor0_.ItemID as ItemID4_0_ FROM dbo.Reports repor0_ WHERE repor0_.ItemID=@p0;@p0 = 1266 [Type: Int32 (0)]
  • 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-27T20:31:50+00:00Added an answer on May 27, 2026 at 8:31 pm

    This is not a bug according to nhusers group. Apparently NHibernate uses one column for the ID and second one for the foreign key. There are also other cases where some of the columns are sent twice. According to the thread it is not worth it to optimize the extra column away because it doesn’t generate additional I/O usage and in normal cases the extra column does not cause too much network traffic.

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

Sidebar

Related Questions

Having some issues getting my head around the differences between UTF-8, UTF-16, ASCII and
Having some issues with the ... in ObjectiveC. I'm basically wrapping a method and
Basically having some trouble with using Hover to hide or show an item. The
I'm creating a database using entity framework code first and I'm having some issues
I'm having some issues with the self parameter, and some seemingly inconsistent behavior in
Having some issues with strcpy... Getting this error: strcpy' : cannot convert parameter 2
Having some trouble with what should be a very simple scenario. For example purposes,
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
Im having some problems getting the Sticky Footer to work on my site. If
Been having some trouble implementing a single-column index in LaTeX. I've been employing the

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.