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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:28:06+00:00 2026-06-14T23:28:06+00:00

I am having some troubles crafting the HQL for a given nHibernate mapping file

  • 0

I am having some troubles crafting the HQL for a given nHibernate mapping file (nHibernate 1.2). This SQL Fiddle example shows the table structures and the results I’m wanting. Basically, I’ll pass in a Jurisdiction and I want all Titles with no jurisdiction or that specific jurisdiction. The current process pulls everything back and filters in code; I’m working to improve this so it filters at the SQL level.

Mapping file looks very similar to this.

<?xml version="1.0" encoding="utf-8" ?>
    <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
        assembly="MyApp.Business"
        namespace="Ap.Bus.Entity"
        default-access="field.camelcase-underscore"
        default-cascade="save-update" >

        <class name="Titles" table="dbo.Titles"  mutable="true" lazy="true">
            <!--Primary Key-->
            <id column="TitleID" name="Id" unsaved-value="0">
                <generator class="identity">
                </generator>
            </id>

        <property column="TITLE" name="Title"/>
        <property column="Enabled" name="Enabled" />

        <bag name="Jurisdictions" table="dbo.Jurisdictions" lazy="false" cascade="none">
            <key column="TitleID" />
            <many-to-many class="Ap.Shared.Jurisdiction, Ap.Shared" column="JurisdictionID"/>
        </bag>
</class>

I’ve tried so many different HQLs and I could never get it to work when I started joining to the Jurisdictions. It was working when only returning enabled Titles without the join.

So, how can I write the HQL to accomplish this?

  • 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-14T23:28:07+00:00Added an answer on June 14, 2026 at 11:28 pm
    select t
    from Title t left outer join t.Jurisdictions as j
    where j is null or j = :someJurisdiction
    

    Possibly you should add “.JurisdictionID” to the last two “j” above.

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

Sidebar

Related Questions

I know it's possible with jQuery, but I'm having some serious troubles with this
I'm having some troubles executing oracle stored procedure from package. I've intalled PL/SQL developer
I am having some troubles understanding the object relationships in Django. I wrote this:
Im having some troubles getting this ajax call to work. The ajax function pass
I'm having some troubles with the beginning of this program. It's supposed to take
I am having some troubles with my script.. when I access http://www.domain.com/this-is-a-topic I want
I am having some troubles on a wsdl file, which on SONIC Workbench is
i'm having some troubles trying to parse an XML file and display the results
I'm having some troubles while reading from an exel in c#. I have this
Using SQL Server 2008... I'm having some troubles in trying to order my rows

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.