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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:34:10+00:00 2026-05-26T05:34:10+00:00

I have a read-only mssql- view , and I want to map it to

  • 0

I have a read-only mssql-view, and I want to map it to nhibernate (using hbm.xml files).
The view is a select that joins two tables. For give an abstract-insight, the select is something like this:

SELECT A.Id As A_ID, B.Id As B_ID,
       A.AttributeA, B.AttributeB,

FROM A INNER JOIN B ON 
     A.Id = B.RootID

It’s a one-to-many relationship between A and B (B entries are dependant/leafs of A entries).

I’m using nhibernate’s hbm.xml files, and I can’t make it to work.

I’d gladly appreciate if someone can enlight me of the kind of XML that I have to use, I guess that as my view has no ID, I have to create a composite-nhibernate id (wich will be the ids os A and B together) but I couldn’t make it to work.
Also the view is READ ONLY so I think that should make the solution easier.

I’m asking the question because none of the others on the site answered this issue (some use fluent-nhibernate,I’m with XML mapping files)

thanks in advance.

  • 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-26T05:34:10+00:00Added an answer on May 26, 2026 at 5:34 am

    Thanks to Andy, that lead me to the final solution.
    I will put the hbm.xml template with my domain-model entities.
    All the columns I’m mapping are varchars/strings (hence my composite ID consist of two strings):

        <class name="Model.Projects.ProjectsLoansView"
               table="V_PROJECTSLOANS" mutable="false">
    
        <composite-id>
          <key-property name="Number" column="Number"/>
          <key-property name="OperationNumber" column="OperationNumber" />
        </composite-id>
    
        <property name="Name" column="Name" not-null="false"/>
    
      </class>
    

    But the mapping was not enough. Nhibernate requests to Override the Equals and GetHashCode function, I will put the exact code of my working VB.Net class that correspond to this XML:

      Public Class ProjectsLoansView
    
            Public Overridable Property Number As String
            Public Overridable Property OperationNumber As String
    
            Public Overridable Property Name As String
    
            Public Overloads Overrides Function Equals(ByVal obj As Object) As Boolean
    
                If (IsNothing(obj)) Then Return False
    
                Dim t As ProjectsLoansView = CType(obj, ProjectsLoansView)
    
                If ((Me.Number = t.Number) And (Me.OperationNumber = t.OperationNumber)) Then
                    Return True
                Else
                    Return False
                End If
            End Function
    
            Public Overrides Function GetHashCode() As Integer
                'TODO: check how to override properly GetHashCode. As is a-read only view it doesn't matter here
                Return MyBase.GetHashCode()
            End Function
    
        End Class
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Now that I have a read-only application working, I am working on the insert
I have read that TempData is backed by session in Asp.Net MVC, but only
I want to create a read-only user in PostgreSQL. The intention is to have
Many library classes in AS3 have read only properties. Is it possible to create
I have a read only combo-box with 5 values in, when the user selects
I have a web page with a read-only text box which shows some HTML
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object
How do I make a textbox read only in mvc? I have included the
I have an sqlite database, and I would like to keep it read-only without
I would like to have a manager process sharing graphs via shared memory, read-only

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.