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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:23:20+00:00 2026-06-04T10:23:20+00:00

I seem to be having a strange problem with one of my database views

  • 0

I seem to be having a strange problem with one of my database views that I have mapped with NHibernate. I’m getting duplicate records for one of the views I have mapped. I have the following view objects

                      WorkDetailView
                       /          \
                      /            \
                     /              \
                    /                \
          PickWorkDetailView    PutWorkDetailView

Each object represents a different view in the database but both PickWorkDetailView and PutWorkDetailView inherit from WorkDetailView because they share many of the same fields.

If I run the following piece of code I get 2 results but if I run the actual database view in SQL Management Studio I get 1 result.

List<WorkDetailView> workList = session.QueryOver<WorkDetailView>()
                                       .List<WorkDetailView>().ToList();

The interesting part is that when I look at all the items in the workList collection above I see one WorkDetailView object and one PickWorkDetailView object. Also if I look at the queries NHibernate is running it issues select from all 3 views (WorkDetailView, PickWorkDetailView and PutWorkDetailView). This does not sound right at all. I can post xml mappings or my fluent mappings if needed.

  • 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-06-04T10:23:21+00:00Added an answer on June 4, 2026 at 10:23 am

    NHibernate supports polymorphic queries. So, when you query that base class it will look for all objects derived from that class.

    You can control this behavior with the polymorphism attribute on the class mapping.

    Implicit polymorphism means that instances of the class will be
    returned by a query that names any superclass or implemented interface
    or the class and that instances of any subclass of the class will be
    returned by a query that names the class itself. Explicit polymorphism
    means that class instances will be returned only be queries that
    explicitly name that class and that queries that name the class will
    return only instances of subclasses mapped inside this <class>
    declaration as a <subclass> or <joined-subclass>. For most purposes
    the default, polymorphism="implicit", is appropriate. Explicit
    polymorphism is useful when two different classes are mapped to the
    same table (this allows a “lightweight” class that contains a subset
    of the table columns).

    In your example you could set polymorphism="explicit" on all 3 mappings.

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

Sidebar

Related Questions

I am having a strange issue that I can't seem to resolve. Here is
I am having a strange problem and I can't seem to figure it out.
I'm having a strange problem using PHP's OAuth PECL library - I seem to
I'm having a very strange problem. When I log stacktraces, they seem to be
I am having a problem that is strange to me but hopefully is not
I seem to be having a strange problem which I can't fully understand. This
I'm having a strange issue that I can't seem to figure out. I tried
I'm having a strange problem that I can't figure out that popped up when
I've been having this strange problem with apply lately. Consider the following example: set.seed(42)
I'm having a strange validation issue that I can't seem to figure out. Why

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.