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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:07:27+00:00 2026-06-13T02:07:27+00:00

I have a mapped view, which I would like to reference in another mapping.

  • 0

I have a mapped view, which I would like to reference in another mapping.

Mapped View:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="Model.TagBE, Model" table="vw_CurrentTag" lazy="true" schema="dbo">
    <id name="Id" column="TAG_HISTORY_ID" type="Guid" 
         unsaved-value="00000000-0000-0000-0000-000000000000">
    </id>

    <property name="Tag" column="TAG"/>
    <property name="TagStatus" column="TAG_STATUS"/>
    <property name="Created" column="CREATE_DATE"/>

    <many-to-one name="Defect" class="Model.DefectBE, Model" fetch="join"
         not-found="ignore" cascade="none" column="DEFECT_ID" />
    <many-to-one name="CreatedBy" class="Model.UserBE, Model" lazy="false" 
         fetch="join" cascade="none" column="CREATE_USER_ID" />
  </class>
</hibernate-mapping>

I would like to use it in this mapping, to get a single TagBE:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
  <class name="DefectBE, Model" lazy="true" table="DEFECT" schema="dbo">
    <id name="Id" column="DEFECT_ID" type="Guid">
        <generator class="assigned" />
    </id>
      <property name="Sn" column="SERIAL_NUMBER" />
      <property name="Description" column="PART_DESCRIPTION" />

      <many-to-one name="System" class="Model.SystemBE, Model" fetch="join"  
           cascade="none" column="SYSTEM_ID" not-found="ignore"/
  </class>
</hibernate-mapping>

The above mappings have been trimmed down for the sake of an example (removed a bunch of properties and and man-to-one relationships not related to the problem at hand.

The many-to-one shown with the name “System” works as expected, and it is just another mapped table, not a view. My problem is that when I try to map the view “vw_CurrentTag”, I can only access the data when I specifically use ISession and ICriteria to get specificaly something of the TagBE class.

When I try to use the following in the DefectBE mapping, it just gives gives null for the TagBE:

<many-to-one name="Tag" class="Model.TagBE, Model" fetch="join" cascade="none" 
     column="DEFECT_ID" not-found="ignore"/>

I have also tried using one-to-one, but i always get null when the TagBE object part of a DefectBE object.

If it’s not possible I can always use a Bag with only 1 entry.

The view is just a query on a single table to return unique Tag column based on other columns.

  • 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-13T02:07:28+00:00Added an answer on June 13, 2026 at 2:07 am

    the many-to-one “Tag” uses the column DEFECT_ID on the table DEFECT to match the primary key of the view TAG_HISTORY_ID which is never equal.

    What you probably want is a one-to-one mapping on the Defect class which points to the DEFECT_ID on the view.

    <one-to-one name="Tag" class="Model.TagBE, Model" fetch="join" property-ref="Defect" foreign-key="none"/>

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

Sidebar

Related Questions

I have a table called Person which I have already mapped in hibernate I
I have a memory mapped file, and a page in a view which is
I have a view which has an Int column which is nullable (let's call
I'm working on a hibernate entity mapping for a database view; when I do
I have a field of type image in my database which is mapped as
I have an Account object that contains an Id field, which is mapped to
How to check that Hibernate mapping configuration matches database? I'd like know if I
I have a view model which consists of a patient object and Visits collection.
I have an AutoMapper profile which currently depends on UrlHelper for the following mapping:
I have a ViewModel I am binding to a view: ProductViewModel model = Mapper.Map<Product,

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.