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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T05:35:54+00:00 2026-05-12T05:35:54+00:00

I have a (several actually) relationship between two objects, the parent object is a

  • 0

I have a (several actually) relationship between two objects, the parent object is a User and the child object is an Incident.
There are four relationships defined between User and Incident:

  1. Property User_created of Incident refers to a User who created the Incident
  2. Property User_modified who modified the Incident
  3. User_reported and finally
  4. User_responsible

All these four properties of Incident references a User object. Like this in the mapping:

<many-to-one name="User_created" class="User, WebbData" fetch="select">
    <column name="created_by" not-null="true" />
</many-to-one>
<many-to-one name="User_modified" class="User, WebbData" fetch="select">
        <column name="modified_by" not-null="false" />
</many-to-one>
<many-to-one name="User_reported" class="User, WebbData" fetch="select">
        <column name="reported_by" not-null="true" />
</many-to-one>
<many-to-one name="User_responsible" class="User, WebbData" fetch="select">
    <column name="responsible" not-null="false" />
</many-to-one>

I want to write a nHibernate expression to fetch all Incidents created by a specific user but I don’t know how to write this expression…
This is what I got so far:

 return session.CreateCriteria(typeof(Incident))
     .CreateCriteria("User")
         .Add(Expression.Eq("Id", UserID))
     .List<Incident>();

but how the heck do I tell nHibernate that it should use the User_created relation and not one of the other three?

  • 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-12T05:35:54+00:00Added an answer on May 12, 2026 at 5:35 am

    I think this works, with the direct assignment of the ID to an entity property:

     return session.CreateCriteria(typeof(Incident))
         .Add(Expression.Eq("User_created", UserID))
         .List<Incident>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 190k
  • Answers 191k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Expanding on Tim's answer, you can use the IN operator… May 12, 2026 at 6:05 pm
  • Editorial Team
    Editorial Team added an answer According to the Javadocs: Statement.close() Releases this Statement object's database… May 12, 2026 at 6:04 pm
  • Editorial Team
    Editorial Team added an answer I figured out how to do it finally, thanks to… May 12, 2026 at 6:04 pm

Related Questions

Several of the resources I've gone to on the internet have disagree on how
I have just ported several of our home-made Outlook COM-addins from Delphi 2007 to
I'm using EF for a set of objects and want to query one type
I have a table (several actually) that contain a lot of columns (maybe 100+).

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.