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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:30:35+00:00 2026-05-13T07:30:35+00:00

An application I’m working on does all its queries by identifier using session.load(). Given

  • 0

An application I’m working on does all its queries by identifier using session.load(). Given the chaos it causes when it can’t find the identifier and throws an exception, I’m thinking of swapping it over to session.get(). But before I do that, it’s such a fundamental part of the system that I want to make sure there’s absolutely no other difference between the two methods. Is there any reason you can think of why the original developers would have chosen load() over get() aside from the handling of invalid IDs?

EDIT: As stated above, I’m fully aware that get returns false and load throws an exception. I’m asking if there’s any OTHER way that they differ.

  • 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-13T07:30:35+00:00Added an answer on May 13, 2026 at 7:30 am

    Isn’t it so that Get never returns a proxy whereas Load does ?

    http://ayende.com/Blog/archive/2009/04/30/nhibernate-ndash-the-difference-between-get-load-and-querying-by.aspx

    I think that this is important:

    Why is this useful? Well, if you know
    that the value exist in the database,
    and you don’t want to pay the extra
    select to have that, but you want to
    get that value so we can add that
    reference to an object, you can use
    Load to do so:
    The code above will not result in a
    select to the database, but when we
    commit the transaction, we will set
    the CustomerID column to 1. This is
    how NHibernate maintain the OO facade
    when giving you the same optimization
    benefits of working directly with the
    low level API.

    From the NH 2.0 ref documentation:

    Note that Load() will throw an
    unrecoverable exception if there is no
    matching database row. If the class is
    mapped with a proxy, Load() returns an
    object that is an uninitialized proxy
    and does not actually hit the database
    until you invoke a method of the
    object. This behaviour is very useful
    if you wish to create an association
    to an object without actually loading
    it from the database.

    If you are not certain that a matching
    row exists, you should use the Get()
    method, which hits the database
    immediately and returns null if there
    is no matching row.

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

Sidebar

Ask A Question

Stats

  • Questions 374k
  • Answers 374k
  • 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 Ruby gems can be written in pure Ruby, or have… May 14, 2026 at 8:02 pm
  • Editorial Team
    Editorial Team added an answer The first version truncates and the second should be fine… May 14, 2026 at 8:02 pm
  • Editorial Team
    Editorial Team added an answer Did you use the expression builder? I am writing a… May 14, 2026 at 8:02 pm

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.