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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:12:21+00:00 2026-05-20T02:12:21+00:00

In my NHibernate mappings I have two objects- Listing and User. One user can

  • 0

In my NHibernate mappings I have two objects- Listing and User. One user can have many listings, and the (Fluent) mappings are set up as such:

Listing:

References<User>(h => h.User).ForeignKey("fk_UserID").Not.LazyLoad().Fetch.Join().Cascade.SaveUpdate();

User:

 HasMany<Listing>(u => u.Listings);

This works fine. However, when I started playing around with QueryOver, I tried:

DbSession.QueryOver<HaveListing>()
    .Where(h => h.IsModerated == false)
    .And(h => h.User.SpammedStatus == false)

Which fails. This, however, works:

DbSession.QueryOver<HaveListing>()
    .Where(h => h.IsModerated == false)
    .JoinQueryOver(h => h.User)
         .Where(u => u.SpammedStatus == false)

Obviously, using the latter is fine, but I wanted to make sure that I’m not missing something- my relationships are defined in the mappings, so do I really need to specify the join each time in order to do a WHERE on User? It would be a waste to include these joins every time when it isn’t necessary.

  • 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-20T02:12:22+00:00Added an answer on May 20, 2026 at 2:12 am

    QueryOver is not LINQ. It uses Expressions to specify property names, but under the hood it’s Criteria, so it’s bound to the same rules (all joins are explicit)

    Unless you have a compelling reason not to, try the following instead:

    DbSession.Query<HaveListing>()
        .Where(h => h.IsModerated == false &&
                    h.User.SpammedStatus == false)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two related objects: ProgramSession and ProgramTask, with a one-to-many relationship. A ProgramSession
I am using Fluent and NHibernate. I have two objects say A & B
I'm witnessing some strange behaviour from Fluent nHibernate. I have two objects involved in
How can I read mapping Xml file generated by Fluent NHibernate API?
Using NHibernate.Mapping.Attributes, I have a entity class with something like: [Class] public class EntityA
NHibernate is driving me 'Nuts'!!! I have the following mapping. Which returns this error
I'm considering using Annotations to define my Hibernate mappings but have run into a
I'm using NHibernate mappings as a defining schema for my app in the development
What tool is there for generating C# classes from NHibernate mappings files?
I'm using NHibernate and Fluent NHibernate to create a mapping file for a domain

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.