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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:29:34+00:00 2026-05-28T14:29:34+00:00

I’m using NHibernate Search for NHibernate 3.0 GA. I have this code in my

  • 0

I’m using NHibernate Search for NHibernate 3.0 GA.

I have this code in my product repository:

public IList<Product> Find(string term)
        {
            var productFields = new[] { "Name", "Description" };
            var importance = new Dictionary<String, float>(2) { { "Name", 4 }, { "Description", 1 } };
            var analyzer = new StandardAnalyzer();
            var parser = new MultiFieldQueryParser(
                productFields,
                analyzer,
                importance);

            var query = parser.Parse(term);

            var session = Search.CreateFullTextSession(NHibernateSession.Current);
            var tx = session.BeginTransaction();
            var fullTextQuery = session.CreateFullTextQuery(query);
            fullTextQuery.SetFirstResult(0).SetMaxResults(20);
            var results = fullTextQuery.List<Product>();
            tx.Commit();

            return results;
        }

In NH Profiler, I can see that a select statement is issued for every product found. What am I missing?

I found this thread from 2009 but presumably this bug has been fixed.

EDIT [06/06/2011]:

My property mappings as far as associations go are as follows:

mapping.HasManyToMany(c => c.Categories)
                .Table("CatalogHierarchy")
                .ParentKeyColumn("child_oid")
                .ChildKeyColumn("oid")
                .Cascade.None()
                .Inverse()
                .LazyLoad()
                .AsSet();

            mapping.HasMany(c => c.Variants)
                .Table("CatalogProducts")
                .Where("i_ClassType=2")
                .KeyColumn("ParentOID")
                .Cascade.SaveUpdate()
                .AsSet();

I don’t really want to eager fetch all categories.

  • 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-28T14:29:35+00:00Added an answer on May 28, 2026 at 2:29 pm

    I solved this in the end. I realised I had not wrapped the whole thing into a transaction. Once I did, the N+1 issue was gone.
    Schoolboy error, but hey, you learn by your mistakes.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
Does anyone know how can I replace this 2 symbol below from the string
I have thousands of HTML files to process using Groovy/Java and I need to

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.