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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:23:49+00:00 2026-06-11T15:23:49+00:00

[Note] See my update further down for the real question. I’ve left the original

  • 0

[Note] See my update further down for the real question. I’ve left the original one in case it’s useful to anyone…

Just trying to get this working. It looks like the Kats/Kittens example from the docs as far as I can tell, but I get a NullReferenceException when I try to use it.

CustomerOrder order = CurrentSession.CreateQuery(
    @"select new CustomerOrder(Name)
      from CustomerOrder o
      left join fetch o.OrderItems as items
      where o.Id = :Id")
    .SetParameter("Id", id)
    .UniqueResult<CustomerOrder>();

If I omit the join fetch (to just bring back ‘CustomerOrder’ withoutthe OrderItems) it works. My CustomerOrder has a constructor that takes a String for ‘Name’ and there are OrderItems records in the database for the order I am retrieving.

What am I doing wrong?

[Update]
I’ve just been reading that what I am trying to do doesn’t really make sense since I am instantiating a new object with some values and what I am doing is effectively trying to fetch the OrderItems as though they belonged to the newly instantiated object, which they don’t.

What I need is an Order with just the Name field populated, along with it’s collection or OrderItem children, ideally with only their ‘Description’ field populated. I want to do this so I am not retrieving all columns back as HQL would normally do (for performance reasons).

What’s the best way to do this?

Thanks

  • 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-11T15:23:50+00:00Added an answer on June 11, 2026 at 3:23 pm

    Thanks to JB Nizet and Rippo for their insights. I tried a few things and performance is fine (for my purposes anyway). If it ever does cause problems I will look at ResultTransformer but I’m sure there are other aspects of my app’s performance that will have a far greater impact on how quickly it runs (which I can optimize via profiling etc etc) than the number of columns being retrieved.

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

Sidebar

Related Questions

Update: this question has been answered (see below). I'll leave it up in case
UPDATE: I found a solution. See my Answer below. My Question How can I
Note: I already checked msdn, it doesn't address my actual question, see below. I'm
I have read on MSDN( see Important note ) that RSACryptoServiceProvider must be disposed.
On this page , I see something interesting: Note that there is a fast-path
Note, this is not a duplicate of .prop() vs .attr() ; that question refers
(Note: This is not a question about what is the best way with code
NOTE: This is a followup to my question here. I have a program that
NOTE: This is an old question and the answers here no longer works (since
Note: I had another similar question about how to GZIP data using Ruby's zlib

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.